how to gradually slow down the speed of the wheel?

I’m new to **Unity ** and trying to make a spin wheel game which works by spinning when i click and gradually slows down with time and the pointer points towards a specific segment referring to the prize.

I’ve a few ways to do this, like creating each segment of the circle as a rigid body and adding a fixed joint to the adjacent segment (10 in total). and putting a hinge joint in the center of a circle but it doesn’t works.

next i tried something with transform.Rotate something like this.

function Update() {

    if (Input.GetMouseButton(0)) {
        
        var tran: float;
        var i = 0;

        tran = Time.deltaTime * 10;
        transform.Rotate(0, 0, -tran);
        
    }
}

it didn’t worked either as the wheel only spins when i click on it, so, slowing down is not a case here too.

i saw this answer most closely related but still no help.

is it something to do with Animation?
any guesses how can i achieve this?

Hey there,

the code you provided is almost correct, you only have to pack the code a bit different:

 function Start(){
		 tran = 0;
		 }

function Update() {
 
     if (Input.GetMouseButton(0)) {
     		if(tran < 0.1f) // makes sure to only accellerate if the wheel is below a certain speed;
        {
        	tran = 100.0f;
        }
     }    
     //reduce speed "tran" by 5% every frame:
     tran = 0.95f * tran;
     // rotate wheel every frame by given speed "tran"
     transform.Rotate(0, 0, -tran*Time.deltaTime);
 }

now you only have to add your variable tran as a float to your class and you should be good to go.
This code should now: Accellerate your Wheel to a value, but only if its speed is below 0.1f and slowly decellerate.
Please bear with me if the code is not correct in syntax, i only write in C# so javascript is really not my territory.