Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Store health independently for tagged gameobjects

$
0
0
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!

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>