# How to create God of War targetting system?

**URL:** <https://forums.unrealengine.com/t/how-to-create-god-of-war-targetting-system/210302>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [March 9, 2021, 10:34am UTC](https://forums.unrealengine.com/t/how-to-create-god-of-war-targetting-system/210302 "2021-03-09T10:34:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lime-Six](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lime-Six](https://forums.unrealengine.com/u/Lime-Six)\
**Post date:** [March 9, 2021, 10:34am UTC](https://forums.unrealengine.com/t/how-to-create-god-of-war-targetting-system/210302/1 "2021-03-09T10:34:22Z")

</div>

Hi everyone

I’m creating a third person melee game and I’m trying to replicate the way that God of War automatically snaps the player character to enemies if they’re within a certain range and radius of them. Jason DeHeras has a quick video of this feature in this tweet

> <https://twitter.com/jasondeheras/status/1358654355029676032>

I’ve seen another post about this and the only response was:  
“On Melee Attack Overlap Sphere to get Potential targets in desired Range (Sphere Radius)  
Filter out Potential targets that are not in certain Angle in front of you or where your Input Direction goes to or any other filtering you want to do (Math)  
Get the Closest one (Math)  
Interpolate towards Target (you might want to have a little offset from him too) or do a simple forward attack if no closeby Target was found.”

It sounds like that would work but since I’m relatively new to UE4, I don’t actually know how to go about doing this, specifically the “Filter out Potential targets that are not in certain Angle in front of you or where your Input Direction goes” part.

Any help would be greatly appreciated.

---

<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:** [March 9, 2021, 11:52am UTC](https://forums.unrealengine.com/t/how-to-create-god-of-war-targetting-system/210302/2 "2021-03-09T11:52:32Z")

</div>

> [@](#):
>
> Filter out Potential targets that are not in certain Angle in front of you or where your Input Direction goes

[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!)

 ![dot.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/5/9/597d9fb74cde50833c1b549e857d470ece049cb8.jpeg)

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 - these are the baddies in my targeting cone:

 ![flitered.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/8/4/84837fa62748a81be12969685c6fbd22c6fa08af.jpeg)

Even though the one on the right is within range of the sphere, it’s not a valid target as it’s _not_ in range of the requested \>.5 dot product value.

To visualise it better, here are the dot values for this setup:

 ![dots.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/0/f/0f01dda3010ef15e9c82112a96af00d341b30f31.jpeg)

---

<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:** [March 9, 2021, 11:55am UTC](https://forums.unrealengine.com/t/how-to-create-god-of-war-targetting-system/210302/3 "2021-03-09T11:55:41Z")

</div>

You could also get lazy-clever about it and use _an actual cone-shaped mesh_ instead of a sphere - this way you get \*filtered \*results only.

---

<div class="post-metadata">

**Author:** ![Lime-Six](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lime-Six](https://forums.unrealengine.com/u/Lime-Six)\
**Post date:** [March 9, 2021, 2:24pm UTC](https://forums.unrealengine.com/t/how-to-create-god-of-war-targetting-system/210302/4 "2021-03-09T14:24:37Z")

</div>

Thankyou so much!! I’ll try that out a little bit later tonight then and get back to you but that looks amazing. I really appreciate that!
