Whats up gents,
Trying to program a rotation from my mainPlayer to an enemyNPC.
3D coordinate system, positive z is the up vector, enemies and player have position and direction vector.
i believe i have the math correct. i was just wondering is there a way to compute this with just the cross product?
get cross product between main player facing and up vector
Vector3 cross = mainPlayer.Facing.Cross(new Vector3(0,0,1));
get the vector from enemy to mainPlayer
Vector 3 inBetween = new Vector3((enemy.Position.X - mainPlayer.Position.X, enemy.Position.Y - mainPlayer.Position.Y, enemy.Position.Z - mainPlayer.Position.Z);
compute the angle via dot product
float dot = cross.dot(inBetween);
if (dot <= 0.0f)
turn right
else
turn left
Thanks for any input or help
