Finish rotation in the same angle of beginning?

Finish the rotation in the same angle of beginning?

Hi Everyone,

I’m trying to make one object that spins to finished his rotation in the same angle of start.

For example if start the spin in angle cero of 360 degree, I want to finished in the same angle.

I’m using a slider to control Speed, so I really need to change this script because depends of other script.

I did try with my function “rotatehome”

Please any advice is very appreciated

var Speed = 1.5;
var rotatehome = true;
 
function Update(){
 
amtToMove = guiNew. vSliderValue * Speed;
 
if(guiNew.showGo == 1){
 
rotatehome = false;
 
transform.Rotate(0,guiNew. vSliderValue * Speed,0);
 
}else{
 
if (rotatehome){
 
transform.Rotate (0,0,0);
}
 
}

Probably the best thing to do, if the rotation that you’re starting from differs from time to time, is record the angle of rotation before you start. Then, when you’re finished rotating, either set it directly or lerp to it.

If you’re always going to be starting and ending at the same rotation, then just set it in the inspector. This way when the object is initialized in the scene you can ensure that the rotation is set correctly and then you can always finish it at the appropriate rotation as well.