Finding out from which direction a vector is approaching another vector

Hey there!
I have a direction vector and an origin for an object that I can use to calculate the direction this object is facing in the world; now I have another object with both these properties as well and I want to find out if the second object is located lefthand or righthand of the original object (relative to its direction, not the world space) - does anyone have an idea which method I could use to do that?
Thanks in advance!

You can start with LookAt from one Vector to the other. It’s a convenience function to calculate the rotation angle (I think) that points toward the other Vector from the first one.

Best way to do this is to create a LookAt vector from original object to the second object. Then do a dot product test between this new LookAt vector and the original object’s Right vector (GetRightVector()).

Use the return value, a float, to determine which side the second object is on. If its less than 0 its on the left side, if its greater than 0 its on the right side.

1 Like

Thank you for the reply; what I ended up doing is taking my target’s direction vector and rotating it by 90° and -90° on the Z axis, then get the impact normal where the second vector hit the first object (it is a straight wall with an even surface along the direction vector), subtract that normal vector from both my rotated direction vectors, get the length of the results and compare them. I am not entirely sure what happens or why, but it seems to work as far as I can tell. Maybe the screenshot explans it better than I do.

Simplify your code with the “FindLookAtRotation” node. It takes in a Start and a Target and gives you the rotation to the Target in a Float.

Did you mean something like this?

FindLookAtRotation gives me a Rotator; not entirely sure how I have to work with it but I posted one approach above.

Are you trying to find the point in space at which the two vectors will intercept each other at a given time, or just trying to see what direction one point is from the other?

It’s strictly about the direction; I just need to know if the second vector is left or right to the other one (in a relative sense) because it changes how I need to proceed.