Hey Guys,
I need some help with this one. I have an animation of one of my characters falling asleep, and another animation of them sleeping.
The problem I am having is I need to start the sleeping animation after the falling asleep animation has finished. I have tried using IsPlaying and PlayQueued but I can’t seem to get it just right. Anyone have any ideas of some JavaScript that could help with this?
Thanks
P.S When will my questions and answers but posted without waiting for an administrator to approve it first?
I tried yield, it said it couldn't be a Coroutine. This is the Script I am using IGG (InGameGUI) refers to another scrip. function Sleeping() { sleeping = true; woddlArt.animation.Play("Snooze"); zs.Play(); } function Update() { if(IGG.sleeping && !sleeping) { move = false; woddlArt.animation.Play("Sleep"); if(IGG.timer2 <= -35) { Sleeping(); } } this way it kinda works, but its unreliable as it depends upon performance of hardware to look good.
– MrSteve1Yield cannot be used in an Update function because you can't halt the engine itself. Make a new function outside Update with the WaitForSeconds component and call that separately.
– LightSourceyield can only be used in a coroutine. something like: > IEnumerator SleepDelay() > { > yield return new WaitForSeconds(2); > woddlArt.animation.Play("Sleep"); > } you call the function in update by using: StartCoroutine(SleepDelay());
– I_Am_The_Minion