Wouldn't the rotation not stop precisely at 360 degrees?

timestamp for reference 8:36

As it is seen when it stops, if the user attempts to spin over and over; wouldn’t the starting eulerAngle y value get larger and larger instead of resetting to (0, 0, 0) due to it not stopping at the same spinAmount each time? This is the issue I had, and I reset the eulerAngle to (0, 0, 0) every time isActive is set to false after a full rotation to correct any imprecision.

Sorry if I worded this strangely, I can reword if better.

    private void Update() => RotatePlayer();

    private void RotatePlayer()
    {
        if (!isActive) return;

        float spinAddAmount = 360f * Time.deltaTime;
        transform.eulerAngles += new Vector3(0, spinAddAmount, 0);
        totalSpinAmount += spinAddAmount;

        if (totalSpinAmount > 360f)
        {
            transform.eulerAngles = new Vector3(0, 0, 0);
            isActive = false;
            totalSpinAmount = 0;
        }
    }

Yes you are correct, it won’t be perfectly 360º
But this is just a testing dummy action, so it’s not intended to be a mathematically perfect action, just a simple action for testing.
If you wanted to make an action like that in your final game then yup resetting it to the same start amount would indeed be one solution. Although it would be resetting to the start amount and not 0 since after moving somewhere the unit will be at a different starting rotation and not necessarily 0.

2 Likes

I agree that would be a better alternative.
Thank you for quickly answering my question!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms