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

[Solved] Enemy Won't Affect Player Health?

$
0
0
So I have this script attatched to an invisible cube with a box collider that is a trigger attatched to my player... public var healthamt : float; var tex1 : Texture; private var attacked : boolean; function OnTriggerEnter(Col : Collider){ if (Col.gameObject.tag == "enemy"){ attacked = true; } } function Update(){ if (attacked){ healthamt -= Time.deltaTime; } if (healthamt > 100){ healthamt = 100; } } function OnGUI(){ GUI.color = new Color32(255, 255, 255, 100 - healthamt); GUI.DrawTexture(Rect(0,0,Screen.width,Screen.height), tex1); } But when my enemy enters the collider it doesn't change my healthamt variable at all. Why, god? Why?

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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