This enemy ai is for Scratch RPG. The red ball is the enemy, (REPLACE THE SCRATCH CAT WITH USUAL SPRITE.) To the creator of Scratch RPG, backpack all the code in both sprites, and put them in your project. Remember to change the enemy sprite with normal sprite
The enemy will attack based on how close you are, your direction and position.