Hi guys,
I am using Raycast to hit the target. When I am shooting the target, the variable keeps decrementing.
For instance: If max health is 100, and I shoot target1 once, the health is amounted to 80.. If I shoot target2 once, the health is amounted to 60 (should be 80 since it is independent from other targets).
What can I do please?
this is my hit collider code:
if (hitInfo.collider.tag == "target")
{
targetHealth = targetHealth - 20;
Debug.Log(targetHealth);
if(targetHealth == 0)
{
Destroy(hitInfo.collider.gameObject);
}
}
Thanks!
↧