Scratch Tutorial 2

How to Make an Enemy AI Tracking Script

⚠️ Important Prerequisite

Before making an enemy chase you, you need to make a sprite named player. Your player character needs to be able to move! If you haven't programmed your player yet, click here to copy the Player Movement Grid from Scratch Tutorial 1.

  1. Step 1

    Scratch AI Step 1

    Select your Enemy Sprite. Get the when green flag clicked block from the Events tab.

  2. Step 2

    Scratch AI Step 2

    Get the forever loop block from the Control tab and lock it right under the green flag block.

  3. Step 3

    Scratch AI Step 3

    Get a point towards (mouse-pointer) block from the Motion tab, drop it inside the loop, and click the dropdown menu to change it to your Player sprite.

  4. Step 4

    Scratch AI Step 4

    Finally, get a move (10) steps block, snap it directly underneath the point block, and change the speed number value to 2 or 3 steps.

← Go to Home