- Home /
Wait() is not working for me!
Ok, so I have made a cutscene in unity and I used this code; var hold : int = 660; //Set this for how long your animation is
function Update () {
//Play animation
wait();
Application.LoadLevel(2); //Your scene
}
function wait () {
yield WaitForSeconds ((hold));
}
LightSource helped me, but it doesn't play the cutscene, it just skips to the game! I am very much of a noob, so be easy on me. :3 Please help!
Answer by Scribe · Mar 29, 2013 at 12:33 AM
Try something like this:
var hold = 660;
function Start () {
wait();
}
function wait () {
//play your cutscene here
yield WaitForSeconds(hold);
Application.LoadLevel(2);
}
Add the code to make your cutscene play where the comment is, I tested this with an audio clip and it worked, hopefully you have success!
Scribe
OH $$anonymous$$Y GOD YOU ARE A$$anonymous$$AZING! THAN$$anonymous$$ YOU x100! If you were here I'd give you a hug!
Answer by Eric5h5 · Mar 29, 2013 at 12:21 AM
There's no point to the wait function, since it just does WaitForSeconds. So, get rid of it and just use WaitForSeconds directly instead. You can't make Update into a coroutine, so move any code that needs WaitForSeconds out of Update.
Ummmm... I'm sorry for not understanding, it's just that I am a complete javascript noob, but I'll try what you said, though I don't get what a coroutine is, I'll try to figure it out. I think I broke it;
var hold : int = 11; //Set this for how long your animation is
function Update () {
//Play animation
WaitForSeconds(11);
Application.LoadLevel(2); //Your scene
}
function wait(hold) {
yield WaitForSeconds ((hold));
}
Your answer
Follow this Question
Related Questions
Animation end trigger 1 Answer
Play anim, javascript 1 Answer
Mouse click on a game object to animate the main camera. 0 Answers
fps MouseLook with animation applied to camera. 1 Answer
cut scene, in-game cinematic how to 1 Answer