Yield or?

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

 var rotation = Quaternion.LookRotation(target);
       transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 1);
      


    transform.position = Vector3.Lerp(transform.position, target, Time.deltaTime * smooth);

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)

StartAnimation();

function StartAnimation() {
    var rotation = Quaternion.LookRotation(target); 
    yield Ani.Mate.To(transform, 1, {"rotation": rotation, "drive": SlerpDrive});
    yield Ani.Mate.To(transform, 10, {"position": target});
}

ah thanks, cant use animate, its for iphone

sorry, just tested your code and it doesnt work, my game objects are just static.

Oh, sorry. Mistook <= with >=. Fixed in the code above.

Does that mean that Ani.Mate shouldn’t be used if you are designing for iPhone?

right, unless you port it to JS / C#
Boo does not work on iphone