Saturday, June 11, 2022
HomeGame Developmentunity - Why rotating backwards is to quick even when i set...

unity – Why rotating backwards is to quick even when i set the time to three?


public IEnumerator DoRotate(float time)
    {
        var newRotation = Quaternion.AngleAxis(180, Vector3.up) * remodel.rotation;

        var progress = 0f;

        whereas (progress < 1)
        {
            progress += Time.deltaTime / time;

            remodel.rotation = Quaternion.Slerp(remodel.rotation, newRotation, progress);

            yield return new WaitForEndOfFrame();
        }
    }

Utilization :

non-public void FixedUpdate()
    {
        
                if (rotateBackwards)
                {
                    StartCoroutine(DoRotate(3f));
                    rotateBackwards = false;
                }
    }

The rotation may be very quick. take much less then a second and for positive not 3 seconds.

Possibly it is higher to do it with out utilizing coroutine ? or one thing within the IEnumerator is incorrect with the time and progress calculation ?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments