I wrote this script:
private var enter : boolean;
//var off: boolean = false;
function Start()
{
enter = false;
}
function OnTriggerEnter (other : Collider){
if (other.gameObject.tag == "Player") {
enter = true;
print ("work?");
//enter = false;
if (Input.GetKey (KeyCode.DownArrow))
{
print ("Click");
Invoke("text", 5);
}
}
}
function text()
{
if(enter){
print ("5 seconds after");
}
}
function OnTriggerExit (other : Collider){
if (other.gameObject.tag == "Player") {
print ("Exit");
enter = false;
}
}
I have one question, when a player enters the trigger and click arrow down after 5 seconds is show in the display "5 seconds after" but this is not happening. What is wrong?
↧