Thursday, June 9, 2022
HomeGame Developmentunity - Easy methods to make the rework rotate backwards however in...

unity – Easy methods to make the rework rotate backwards however in FixedUpdate as a substitute in coroutine?


First time I attempted this technique:

public IEnumerator DoRotation(float time)
{
    var newRotation = Quaternion.AngleAxis(180, Vector3.up) * rework.rotation;
    var progress = 0f;

    whereas (progress < 1)
    {
        progress += Time.deltaTime / time;
        rework.rotation = Quaternion.Slerp(rework.rotation, newRotation, progress);
        yield return new WaitForEndOfFrame();
    }
}

Then I used a flag helper inside Replace() to start out the coroutine solely as soon as however when the rework rotates backwards it additionally begin shifting and when shifting the rework it shakes/stutters.

I had the identical drawback with one other rotation half and when shifting it to FixedUpdate() it solved the shaking drawback.

I am undecided why it is shaking like that.

I attempted this within the FixedUpdate:

var newRotation = Quaternion.AngleAxis(180, Vector3.up) * rework.rotation;
rework.rotation = Quaternion.Slerp(rework.rotation, newRotation, Time.deltaTime * rotationSpeed);

Nevertheless it retains rotating the rework 180 levels the other way nonstop.

Easy methods to make the rework rotate backwards in FixedUpdate as a substitute of in coroutine?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments