var animationclip : String; //= maybe something goes here??
var ObjectToAnimate : GameObject;
var destroy : GameObject;
var trigger : GameObject;
//var waitforseconds : something?? or maybe I’m not even close??
function OnTriggerEnter (player : Collider){
if(player.tag == "Player")
yield WaitForSeconds(3); ObjectToAnimate.animation.Play(animationclip);
trigger.Destroy(destroy);
}
This is what I have and of course it all works, BUT its 3 second delay on everything. I made some comments on my script so you can see my thoughts. I’m trying to figure out what do put there. I would like to be able to change the “seconds” in the Var/Inspector so I can reuse this on other things.
Having my trigger destroy after I collide with it is awesome so the animation doesn’t replay if I hit it again. I figured that out on my own to! hehe
any ideas on the “wait for seconds” as a variable?? **It would be the delay for the animation of course.
This is the answer to my question. In case anyone else has the same question.
var animationclip : String; //the name of your animation clip goes here
var ObjectToAnimate : GameObject;
var destroy : GameObject; //i'm destorying my trigger so it won't re-activate.
var trigger : GameObject; //name of the trigger object
var seconds : float; //delay on animation if any. 0=None
function OnTriggerEnter (player : Collider){
if(player.tag == "Player")
yield WaitForSeconds(seconds); ObjectToAnimate.animation.Play(animationclip); trigger.Destroy(destroy);
}