Can someone point me to the type of math that is need to handle this.
I have two examples. Top left and lower right.
I have an enemy in red, its view direction is the black line. Then have the player in Blue, with their view direction being the black line.
I’ve done a dot product of the two directions to get the angle between the two people. But What I’m looking for also, to determine if I’m on their left side vs. right side.
Adding the 2 vectors will give you a resultant vector, then subtract the resultant vector from your current position so position vector - resultant vector if the result is positive (bigger than zero) then the player is at the left (at the positive side) otherwise if the result is negative the player would be at the right side.
Another solution is comparing the angle between those two vectors with the polar representation of the position vector on a specific axis (I don’t know how to do this on 3d).
Dot product with their left vector. Positive 0…1 means they are on the left. Negative 0…1 means they are on the right. And the result is usually even suitable for plugging into steering algorithms.
left vector = obj.getRotation().mult(Vector3f.UNIT_X)
…at least in JME standard “look down Z axis” orientation.
Example of camera being at different angles displaying the texture. There are 8 angles of each player and a player has a view direction shown by the white lines. White lines shows the area where they will pickup the enemy and go into attach mode.
Vector3f left = looker.getLocalRotation().mult(Vector3f.UNIT_X);
Vector3f targetRelative = target.getLocalTranslation().subtract(looker.getLocalTranslation());
// If we want to use it for steering input:
targetRelative.normalizeLocal();
float leftness = targetRelative.dot(left);