# How do I calculate when a character is within an angle?

**URL:** <https://forums.unrealengine.com/t/how-do-i-calculate-when-a-character-is-within-an-angle/666783>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [October 11, 2022, 1:39am UTC](https://forums.unrealengine.com/t/how-do-i-calculate-when-a-character-is-within-an-angle/666783 "2022-10-11T01:39:35Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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:** [October 11, 2022, 6:40am UTC](https://forums.unrealengine.com/t/how-do-i-calculate-when-a-character-is-within-an-angle/666783/5 "2022-10-11T06:40:27Z")

</div>

The linked thread seems to have everything you need, but here’s a more visual example - perhaps that helps:

> [@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…

Essentially, you want to use `dot product` and, optionally, convert it to angle. There are more examples linked under the above post.

---

_[View the full topic](https://forums.unrealengine.com/t/how-do-i-calculate-when-a-character-is-within-an-angle/666783)._
