- Home /
Yield waitforseconds not consistent for animation-unity2D
While trying to delay the execution of the code, yield waitforseconds is not working consistent . yield waitforseconds works properly except for a few times . Below is the code snippet
function teleport_me(){
if (teleport==true){
anim.SetTrigger("teleport_in");
yield WaitForSeconds (0.5);
other.gameObject.transform.position = Vector3(target.transform.position.x, target.transform.position.y,0);
}
teleport=false;
}
What inconsistency are you seeing? A more detailed description would help us to help you. A reproducible example would help even more.
The function teleport_me() is called everytime and the animation is played .However sometimes the control doesnt go to the line after yied . So the statement after yield is not executed everytime . Hope this helps
Your answer
Follow this Question
Related Questions
Unity 2d animation acting strange 0 Answers
Animator - Wait until animation finishes 3 Answers
Single Time Animation Play 1 Answer
Problem with 'animation.CrossFade' and 'fadeLength'. 0 Answers
Why don't my animations immediately change in Unity 2D? 2 Answers