- Home /
This question was
closed Feb 10, 2018 at 01:09 PM by
NoMoreBoss.
Question by
NoMoreBoss · Feb 10, 2018 at 06:39 AM ·
gameobjectrotateangle
How to know 3DGameObject rotating clockwise or counterclockwise
The rudder LookAt the Hand(Target) and rotate. I try to use cross and dot in my script, but it's doesn't work. how can I know this 3DGameObject(Rudder) is rotating clockwise or counterclockwise? Thank you.

Vector3 VectorCross;
private void Cross( Vector3 terget, Vector3 Rudder ) {
VectorCross = Vector3.Cross( terget, Rudder );
Debug.Log ( VectorCross );
if ( Vector3.Dot( VectorCross, Vector3.up ) > 0.0 ) {
Debug.Log("clockwise ");
} else {
Debug.Log("counterclockwise");
}
}
1.jpg
(51.3 kB)
Comment
Answer by hexagonius · Feb 10, 2018 at 09:18 AM
the cross product only works with directions, where target is a position. it's also not clear if you want the rotation direction relative to up, or to itself.
Anyway, you need the direction rudder center to target and either up or it's last up. you then don't need the Dot from your Cross because it's sign on z axis in rudder space will tell you (if that's still forward)