AI Attack Range

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.

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

1 Like