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?