Stop player from body blocking AI

I have a simple AI which will either do a ranged attack or a melee attack based on the distance.


The problem here is with ranged attack. The AI will try to move slightly in radius around itself, then fire a projectile and move again. The problem is that is something (like the player) blocks it during the movement, it will get stuck and never fire a projectile and never go for a melee attack.


How do I cancel the ranged attack movement and switch to melee if the player is close enough? Would I have to run the ranged check on loop or is there a better method?

I found a way to prevent that trough collision checks:


I added this “On component hit” dispatcher, which then is assigned to an event inside the ranged movement task.

When the monster is touched by an enemy, it will finish executing the ranged attack and re-o the distance check, allowing it to go for melee.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.