Check Target vector if it was point in the left or right side of forward vector?

Hi,

I have a very stupid math question here.

I try to find if the enemy was in the left side or right from my character forward vector.

Let’s say that I have

character.transform.forward

and the enemy direction vector the got from

Vector3 targetVector = enemy.transform.position - character.transform.position;
targetVector  = targetVector.normalize;

How do I know the the target vector are in the left or right side from my character forward

and also how about front or back of my character ? I heard this case was use Dot product to see if it become negative value or not ? isn’t that the right way?

Sorry for this silly question.

Thank you,

The left/right thing is surprisingly tricky but it is answered in this thread. You are right about the forward/backward test, though. The dot product of the two vectors is positive if the target object is in front, negative if behind and zero only if it is exactly to the side.

1 Like