I have this script:
#pragma strict
var lives = 3;
var livesTexture : Texture2D[];
var livesTextureSize = 30;
function OnGUI ()
{
var livesTextureRect = Rect(10,5,livesTextureSize,livesTextureSize);
for (var i : int = 0; i < lives; i++)
{
GUI.DrawTexture(livesTextureRect,livesTexture[i], ScaleMode.ScaleToFit, true, 0.0f);
livesTextureRect.x += livesTextureSize + 10;
}
}
function OnTriggerEnter (myTrigger : Collider) {
if(myTrigger.gameObject.name == "Enemy")
{
print("work?");
if (lives-1 >= 0)
livesTexture[lives-1] = null;
WaitForSeconds(2);
Invoke("life", 2);
}
}
function life()
{
Invoke("life2", 2);
lives --;
}
function life2()
{
Invoke("life3", 2);
lives --;
}
function life3()
{
lives --;
print("YOU DEAD");
}
When I enter a trigger for tag "enemy" in general does not detect it. No shows "print (" work ");" What is wrong?
Script added to the First person controller.
The enemy has the tag "Enemy"
↧