unity血条 slider中的 value怎么获得函数中的参数hp的值 hp就是int型
publicinthp=100;publicSliderBlood;publicvoidHit(int_damage){//InstantiatehitFXInstant...
public int hp = 100 ;
public Slider Blood;
public void Hit(int _damage)
{
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//Remove damge value form health
hp -= _damage;
//If health is less than 0
if (hp <= 0)
{
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//We are dead
dead = true;
//Set time scale to 0
Time.timeScale = 0;
}
}
public void Hit(int _damage)
{
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//Remove damge value form health
hp -= _damage;
//If health is less than 0
if (hp <= 0)
{
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//We are dead
dead = true;
//Set time scale to 0
Time.timeScale = 0;
}
}
public void Hit(int _damage)
{
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//Remove damge value form health
hp -= _damage;
//If health is less than 0
if (hp <= 0)
{
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//We are dead
dead = true;
//Set time scale to 0
Time.timeScale = 0;
}
}
void OnGUI()
{
GUI.Label(new Rect(10,10,300,300),"HP: " + hp.ToString());
} 展开
public Slider Blood;
public void Hit(int _damage)
{
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//Remove damge value form health
hp -= _damage;
//If health is less than 0
if (hp <= 0)
{
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//We are dead
dead = true;
//Set time scale to 0
Time.timeScale = 0;
}
}
public void Hit(int _damage)
{
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//Remove damge value form health
hp -= _damage;
//If health is less than 0
if (hp <= 0)
{
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//We are dead
dead = true;
//Set time scale to 0
Time.timeScale = 0;
}
}
public void Hit(int _damage)
{
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//Remove damge value form health
hp -= _damage;
//If health is less than 0
if (hp <= 0)
{
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//Instantiate hit FX
Instantiate(hitFX,transform.position,Quaternion.identity);
//We are dead
dead = true;
//Set time scale to 0
Time.timeScale = 0;
}
}
void OnGUI()
{
GUI.Label(new Rect(10,10,300,300),"HP: " + hp.ToString());
} 展开
展开全部
你可以定义一个属性来保存角色的HP上限呀,HP的现有量/HP上限的比值就是血条进度条的值了呀
追问
具体怎么做啊?
追答
public float maxhp = 100 f;
int hp;
void Start()
{
hp=maxhp;
}
void OnGUI()
{
slider.value=hp/maxhp;
GUI.Label(new Rect(10,10,300,300),"HP: " + hp.ToString());
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询