My object rotates and moves to a new position, is there anyway I can get the rotation to happen first and then after its complete move the object, all of the following is in Update so the animation works…ive tried yield but doesnt work
You can use a coroutine and a simple “yield;” to wait for the next frame. This way it will behave just like Update() and you can wait for one animation to finish before starting the other.
StartAnimation();
function StartAnimation() {
var rotation = Quaternion.LookRotation(target);
var startTime = Time.time;
while (startTime + 1 >= Time.time) {
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 1);
yield;
}
startTime = Time.time;
while (startTime + 5 >= Time.time) {
transform.position = Vector3.Lerp(transform.position, target, Time.deltaTime * smooth);
yield;
}
}
This also seem like a fit case for AniMate, which would turn it into this: 8)