Issue with absolute rotation un unity

hi folks i try to rotate a plane on one axis and unity became weird, so i put the script on a cube, and he absolutely not does what he as to do,

here is the code :

Quaternion target2 = Quaternion.Euler(pos_rotation, 90, 0);
transform.rotation = Quaternion.Slerp(transform.rotation, target2, Time.deltaTime * smooth);

pos_rotation = pos_rotation + 1;

i can post all the program if needed, i have tried to use the other formula, but i need to rotate absolute

thanks for your help

f.

Option 1: Try RotateTowards instead of Slerp.

Slerp (and all Lerp fucntions) are meant to be used as:
current = Lerp(start, end, zeroToOneValue)
This form is:
current = Lerp(current, end, someLowNumber)
And it produces a slightly unpredictable turning speed that’s a little odd sometimes.

Option 2: avoid that entirely, just set the rotation directly to the value of target2. I think you’ll find that pos_rotation is moving MUCH faster than you think it is - so when it gets around to the “other side” of the current rotation, your object will start turning the other way instead.

You can use Time.deltaTime to make it an amount of degrees per second (right now it’s 1 degree per frame).

Quaternion target2 = Quaternion.Euler(pos_rotation, 90, 0);
transform.rotation = target2;
pos_rotation = pos_rotation + Time.deltaTime * degreesPerSecond;

Hi Starmanta, i saw your reply resterday and have tested it, its far better, btw i notice that the unity comunity is more alive than Crytek…

Thanks for your fast reply

f.