how to control Quaternion.Slerp rotation direction

I have like a chain sequance were the object has to rotate either direction from left to right or oposite.

if (strip*.transform.position.x > z1)*

{

  • target = sid1.transform.rotation; the object deg is 90,0,0 and has to go to 90,180,0*
    strip.transform.rotation = Quaternion.Slerp(strip_.transform.rotation, target,Time.deltaTime * power);_

where z1 is empty object to tell me that the object has to turn either up clockwise or down unclockwize, simple like a bicycle chain rotating 180 deg.
//
same on the other side I have z2
The problem is when going unclockwize the object rotate clockwize until it reach’s the target deg the long way which is wrong! how can I tell the Slerp function to turn correct.

Not entirely sure what you’re asking…
But you can send a negative angle to Slerp to send it the opposite way. Perhaps you can set a variable to either 1 or -1 and multiple your rotation by that variable. If that variable is 1 it will go clockwise; if it’s -1 it will rotate anti-clockwise

ok solved insted of 0 deg as target from 180 deg I used

target = Quaternion.Euler (0, 0, -1);

and insted of 180 deg as target from 0 deg I used

target = Quaternion.Euler (0, 0, 178); and that solved for unti-clockwise