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
- forever
- move 4 steps
- 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.
This guide is provided for educational purposes. Scratch screens and terms may change over time, so please check the official Scratch website as well.