How to check if an object is on the left or right side of another?

Howdy folks, I’ve been searching around for this problem and there’s a lot of other threads, but I can’t seem to get my specific problem solved…

I have an AI ship that is controlled by calling a custom rotation function. So in order to control it, I need to be able to tell if the target ship is to the left or right of the AI character. I struggle with vector maths, so please treat me like a potato in this regard…

I suspect that what I want is an inverted version of another superb response (here) to building a clockwise detector. That script returns true if the actor containing the function is clockwise from the provided target, I want to return true if the target is clockwise from the actor containing the function, since I need the AI to be able to turn and then stop when facing the target.

I really hope this makes sense to someone out there…
Thanks in advance,
Dukes


Here I check that this Actor is on the left or right side of the trigger, I calculate the dot product of “right vector of trigger” and “vector from actor to trigger”, if these two vectors < 90 degrees, then the dot product > 0, and vice versa.

6 Likes