What I’m going to implement is to rotate a rigid body, the first way is to rotate it in the FixedUpdate method, and the second way is put the rotation into a coroutine.
I thought they would result the same, but I was wrong. Rotation in FixedUpdate works just as I supposed, while rotation in coroutine doesn’t.
#2 rotate rigidbody in coroutine:
void Start()
{
StartCoroutine(“TestRotation”);
}
IEnumerator TestRotation()
{
while (true)
{
rbody.MoveRotation(rbody.rotation * Quaternion.Euler(0, 5, 0));
yield return new WaitForFixedUpdate();
}
}
So, what’s wrong with the implementation by coroutine? What’s the difference between FixedUpdate() and WaitForFixedUpdate()? How could I make it work by coroutine??
I’m pretty much doing the same thing on my game only to add force up for a jetpack, didn’t encounter a problem here.
what happens when the coroutine is used? check the inspector for and weird values and double scripts
rb.AddForce (dir.normalized * power, ForceMode.Acceleration);
yield return new WaitForFixedUpdate ();
First does rotation when FixedUpdate() is done, second does it before it starts.
The documentation says “Waits until next fixed frame rate update function.”
I might be wrong, but that’s the only thought I had at moment.
Well, damn it, SparrowsNest, look at the date of the OP