I need help on this problem; this problem involves with GUITexture as enemy health. When the game starts I always see the enemy’s health bar and I’m not even close to one. Any ideas would be appreciated.
2 Answers
2-
Place a Collider on your player.
-
Mark it as Trigger.
-
Add a script to the player.
-
In the script add the following methods:
protected void OnTriggerEnter( Collider other )
{
//if other is enemy, display enemy health bar
}protected void OnTriggerExit( Collider other )
{
//if other is enemy, hide enemy health bar
}
Thank you for that. I honestly can’t believe that was the issue. Thank you.
I try but nothing work so far. Is there a function that hides the GUI or something like that because I'm been on this for 12 times now. Here is my code for the advice you give me and my code for the enemy's health.
– GamerBotvar sight : boolean; function OnTriggerEnter(other : Collider){ if(other.tag == "Monster"){ sight = true; } } function OnTriggerExit(other : Collider){ if(other.tag == "Monster"){ sight = false; } } function Start () { } function Update () { if(sight){ } }
– GamerBot
accept as answer?
– OP_toss