# AI Attack Range

**URL:** <https://forums.unrealengine.com/t/ai-attack-range/383856>\
**Category:** Community & Industry Discussion\
**Tags:** range, attack, ai-controller, unreal-engine, question\
**Created:** [February 3, 2017, 7:21pm UTC](https://forums.unrealengine.com/t/ai-attack-range/383856 "2017-02-03T19:21:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Knives008](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Knives008](https://forums.unrealengine.com/u/Knives008)\
**Post date:** [February 3, 2017, 7:21pm UTC](https://forums.unrealengine.com/t/ai-attack-range/383856/1 "2017-02-03T19:21:38Z")

</div>

So I have a blueprint which will fire when the enemy AI Senses the player. The problem is he is a melee character and I only want him to attack when he is within melee range of the player character. Still fairly new to blueprints so any help would be appreciated. Here’s what I have so far.

 ![124875-fdd.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/9/d/09df182472b474b00a4c3f1d8e2a8ebd21a38599.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_210522a1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_210522a1](https://forums.unrealengine.com/u/anonymous_user_210522a1)\
**Post date:** [July 24, 2017, 7:00pm UTC](https://forums.unrealengine.com/t/ai-attack-range/383856/2 "2017-07-24T19:00:41Z")

</div>

if((ActorLocation - EnemyLocation).Size() \<= MeleeRange)

```
{

     //execute your code

}

```

make these nodes:

1. Vector - Vector (GetActorLocation - TargetCharacter-\>GetActorLocation)
2. GetVectorLenght (or Size or however it is called (long time since I did BP, I do c++ now))
3. \<= (floats)
4. Branch

Put one into 2

Put 2 into 3, with your melee range second

And execute your melee logic on the true branch

Hope this helps

-
