Vector3.Angle does not give me the sign!

Hello,

I have a problem with Vector3.Angle() function.
I’m using it to drive a ship. I need to rotate it to point a specific way-point (the ship must go, slowly, to the waypoint).

The problem is Angle() does not give me the sign. For example, if the waypoint is on the right of my ship, Angle() give me “90 degrees”. But I get same result if my waypoint is on the left!

It means I cannot find the right rotation direction, and sometimes it seems the commander of my ship is a “mad” :slight_smile: In fact it starts to rotate making the longer rotation.

I hope I was clear in my explanation :sweat_smile:

Can you give me a small hint just to quickly discover rotation direction based on ship “Forward” (direction)?

Thank you!

You can use the cross product to figure out the appropriate direction. It returns a vector that is perpendicular to the other two vectors, and although the overall number probably isn’t too important for you, the axis that it points to should be. Let me know with a new post if you need any more help.

Great! Thank you!
If cross product on y-axis return a positive number I will rotate to counter-clockwise, instead if y-axis is negative I will rotate clockwise.

Thank you for this great hint :wink: