Calculate left or right of wall

May not be 100% precise example but see if this gets you any closer:

Image from Gyazo

3 Likes

hey guys I have a bunch of points on either side of this wall (hidden until they glow), I just want to highlight the points that are on the side of my cursor. So in the picture below, that would be on the left side of this wall. So the points on the left should only glow not the right.

How do I determine if the points are on the side of the cursor? Its an interesting vector math problem…

However this is not working for me as you can see from the picture. Both left and right points are glowing. Anything wrong with my math?

324030-sadsadasd.png

My solution is:

  • get the direction vector from wall to point (B)
  • get direction vector from wall to cursor (A)
  • get dot product of A and B
  • if dot product is positive, then that means the points is in the direction of the cursor from the wall

If this helps others like me, this is to make a RTS cover system mechanic similar to CoH2 or Men of War

Thank you, something like this worked for me.

  • Get the right vector of the wall (A)
  • Get the unit direction from wall to a spot next to the wall (B)
  • Get Dot product of A and B (D)
  • Then to factor in which side is on the side of the cursor I got direction from wall to cursor (C) and got the dot product of C and A (E)
  • If D * E > 0 then the spot is on the correct side of the wall.

I might’ve over complicated it but it works.

For anyone interested, this is to create a RTS cover system similar to Company of Heroes 2 or Men of War

Sorry for the revival, but how could this be done for every rotation? the way i have it set up, it only works when facing X and Y positive