Question by
robingroot99 · Jun 24, 2020 at 03:21 PM ·
c#collisioncollidercharactercontroller
How to manage healthbar with collision?,How to manage health with collision
I can't figure out why my character is not taking any damage.
The projectile script:
void onTriggerEnter(Collider other)
{
PlayerCharacter player = other.GetComponent<PlayerCharacter>();
if(player !=null)
{
player.Hurt(damage);
}
Destroy(this.gameObject);
}
The player script:
void Start()
{
_health = 5;
}
public void Hurt(int damage)
{
_health -= damage;
Debug.Log("Health: " + _health);
healthText.text = "Health: " + _health.ToString() + " / 5";
}
So if anyone could help me that would be great, if you need more info just ask.
Comment