Home > Net >  How can I do a rotation to the target point from right?
How can I do a rotation to the target point from right?

Time:09-07

I have a wheel. I want the wheel to spin towards the target points.

Turns right on 1-2-3-4-5. but it turns left to 6-7-8 points. because it takes a shorter way to turn from the left side. (The points are kept in the "target" variable)

I want the wheel to always turn to the right to point to the target. How can I do a rotation to the target point from right?

enter image description here

My code:

 targetRotation = Quaternion.LookRotation(new Vector3(
            target.transform.position.x,
            0,
            target.transform.position.z)
            - transform.position);
    transform.rotation =
        Quaternion.Lerp(transform.rotation,
        targetRotation,
        3f * Time.deltaTime)
        ;

CodePudding user response:

Try this solution by LiterallyJeff. Unity Forum link

  • Related