# How to tell if something is in front of the player, and if so by how much?

**URL:** <https://forums.unrealengine.com/t/how-to-tell-if-something-is-in-front-of-the-player-and-if-so-by-how-much/487541>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [August 17, 2021, 2:09am UTC](https://forums.unrealengine.com/t/how-to-tell-if-something-is-in-front-of-the-player-and-if-so-by-how-much/487541 "2021-08-17T02:09:29Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [August 17, 2021, 8:48am UTC](https://forums.unrealengine.com/t/how-to-tell-if-something-is-in-front-of-the-player-and-if-so-by-how-much/487541/3 "2021-08-17T08:48:59Z")

</div>

Can be simplified to this:

 ![346513-screenshot-3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/c/3/5c3b02d773d9c937caa03f978e178cee0176fe83.png)

And that’d need no normalisation, too. More here:

> [@How to create God of War targetting system?](https://forums.unrealengine.com/t/how-to-create-god-of-war-targetting-system/210302/2):
>
> [The Dot Product](https://en.wikipedia.org/wiki/Dot_product) of 2 directional vectors will be in range of -1 to 1. Anything that’s above 0 is in front of you, anything below 0 is behind (and every other value in between matters, too!) I grab all the actors around the player using a Sphere Overlap (as in the original suggestion) and loop through the elements of the array, checking my angles - Dot player’s forward and the direction to each target. For dot values greater than .5 I mark the target, and add that actor to the array…

---

_[View the full topic](https://forums.unrealengine.com/t/how-to-tell-if-something-is-in-front-of-the-player-and-if-so-by-how-much/487541)._
