Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Discrepancy in simple spinning animation using script.

Discussion in 'Animation' started by aks20997, Nov 21, 2023.

  1. aks20997

    aks20997

    Joined:
    Jul 31, 2023
    Posts:
    1
    I am creating a roulette-type game in Unity for that I need to spin the roulette wheel and the ball and stop both of them at once.

    The problem I am facing is if the ball is supposed to stop at an angle of 240f then instead it stops on 241f.

    In order to fix this, I implemented this line of code,

    Code (CSharp):
    1. pivot.transform.localEulerAngles = new Vector3(0, 0, -thetaBall);
    But on running in Android, the ball appears to jump on that number.

    Is there any way I can make the animation smoother and make it refresh-rate-independent?

    I am not using physics, I am simply generating the angle randomly from the given array, and making the ball stop on the choosen angle and treating the index of the choosen angle as the winning number.