# Calculate left or right of wall

**URL:** <https://forums.unrealengine.com/t/calculate-left-or-right-of-wall/475471>\
**Category:** Community & Industry Discussion\
**Tags:** math, direction, unreal-engine, vector, question\
**Created:** [December 5, 2020, 9:18pm UTC](https://forums.unrealengine.com/t/calculate-left-or-right-of-wall/475471 "2020-12-05T21:18:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NorthWeapon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NorthWeapon](https://forums.unrealengine.com/u/NorthWeapon)\
**Post date:** [December 5, 2020, 9:18pm UTC](https://forums.unrealengine.com/t/calculate-left-or-right-of-wall/475471/1 "2020-12-05T21:18:41Z")

</div>

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/c/6/2c66c6a427cac99fe6b9d395606037059959c9d9.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

 ![324031-213as.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/3/e/e3eba84f7f61f7755788c40df7c359a2e775f4dd.png)

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

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [December 5, 2020, 10:13pm UTC](https://forums.unrealengine.com/t/calculate-left-or-right-of-wall/475471/2 "2020-12-05T22:13:02Z")

</div>

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

 ![324033-screenshot-10.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/7/d/a7deaf6edc6ed42d9355b363105f02ed31963692.jpeg)

[![Image from Gyazo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/4/a/44ad5b51d69d8ccb32e6b78d55b63156eaf3ef54.gif)](https://gyazo.com/efc989efffa446ae43a891a6373bc6d2)

---

<div class="post-metadata">

**Author:** ![NorthWeapon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NorthWeapon](https://forums.unrealengine.com/u/NorthWeapon)\
**Post date:** [December 6, 2020, 5:38am UTC](https://forums.unrealengine.com/t/calculate-left-or-right-of-wall/475471/3 "2020-12-06T05:38:53Z")

</div>

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

 ![324068-sad213.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/f/e/6feae564f43694adb6c8964028b12ed102b64676.png)

 ![324067-213124.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/1/f/51f8fc2c6966993dcfab73681634eea8df631a66.png)

---

<div class="post-metadata">

**Author:** ![awdlkasdf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@awdlkasdf](https://forums.unrealengine.com/u/awdlkasdf)\
**Post date:** [February 10, 2024, 8:12am UTC](https://forums.unrealengine.com/t/calculate-left-or-right-of-wall/475471/4 "2024-02-10T08:12:51Z")

</div>

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
