玩家的血量怎么减不了
玩家的血量怎么减不了??
玩家的血量怎么减不了??
2017-11-03
我也发现玩家的血减不了,但是EnemySpider的血是可以减的
GameObject.cs
void Start()
{
playerHealth = player.GetComponent<Health>();
healthText.text = playerHealth.health.ToString();//UI的healthText的内容
}
void OnDamage( Health health )
{
// playerHealth = player.GetComponent<Health>();
// healthText.text = playerHealth.health.ToString();
if (health == playerHealth)
healthText.text = health.health.ToString();//改变UI中的health,该Health应该为player的health
}
health.cs中
public void OnDamage( int damage = 1 )
{
health --;
damageSignals.SendSignals(this, this);//生命值减一,并发送信息
if (health == 0)
deathSignals.SendSignals (this, gameObject);
}
void OnEnable()
{
health = maxHealth;
}
举报