- Home /
Jerky camera when using IEnumerator
One last question before I head off to bed.
if(wallIsMoving || pirateIsMoving) {
goLookAtTarget();
} else {
//StartCoroutine(delayGoToCannon()); Jerky camera if i use this
goLookAtCannon(); //I don't get a jerky camera with this
}
private IEnumerator delayGoToCannon() {
yield return new WaitForSeconds(3);
goLookAtCannon();
}
When I call goLookAtCannon() function, the camera uses iTween to move to the cannon. Simple enough right? But when I use this IEnumerator to delay the function for 3 seconds before moving to the cannon, it looks like I have 3 FPS when it moves to the cannon, although my FPS is perfectly fine. The goLookAtCannon function all it does is call the iTween.MoveTo method and sets some boolean values.
Any ideas why this is happening? Thanks for any help!
Odd. Have you tried using Invoke to call the function after 3 seconds, would be interesting to know if that provokes the same effect.
Ah good idea. I'll give that a shot when I get back to it and I will let you know.
Are you sure you're not calling delayGoToCannon() multiple times?
Ah yes I am! I forgot to set a boolean value. That sure does fix the problem. Invoking the method fixed it as well. Thanks to both of you guys.