NEW Explore the Scratch Block Dictionary, tutorials, textbook, and classroom guides

Start learning →

How to Make an Enemy Patrol Back and Forth in Scratch

📌 What you will learn

Turn 180 degrees whenever the enemy crosses left or right patrol limits.

Minimal Working Block Recipe

Turn 180 degrees whenever the enemy crosses left or right patrol limits.

Test this minimal version first, then tune numbers like speed, gravity, or timing to match your game feel.

Make an Enemy Patrol Back and Forth script
  1. forever
  2. move 4 steps
  3. if <(x position) 150> or <x position (-150)> then turn 180 degrees

Try it: Reliable platform or corridor patrol enemy.

Debugging Checklist & Next Steps

If it behaves unexpectedly, verify initial variable resets on the green flag and check that continuous checks sit inside a forever loop.

Related Deep-Dive Guide Explore full mechanics and variations. Learn more → All 120 Scratch How-To Recipes Return to the reverse lookup index. Learn more →

This guide is provided for educational purposes. Scratch screens and terms may change over time, so please check the official Scratch website as well.