Fixing horizontal wall collision in Griffpatch platformer tutorial
💡 Stuck debugging platformer collision issues? Player getting trapped in walls? 🚀 Get Help Now
PlatformerDad88
Posted on July 24, 2025 • Intermediate
🎮 Griffpatch platformer collision bug - player stuck in walls
Hey everyone! My son and I have been working through Griffpatch’s amazing platformer tutorial for hours, but we’re running into a frustrating issue. Everything seems to work correctly except the player keeps getting stuck horizontally in walls and ground! 😤
We’ve double-checked our code multiple times but can’t figure out what’s going wrong. The vertical collision works fine, but horizontal movement causes the player to clip through and get trapped.
Has anyone else encountered this issue? We’re following the tutorial exactly but something must be off. Any help would be greatly appreciated! 🙏
RokCoder_Expert
Replied 54 minutes later • ⭐ Best Answer
I see the issue @PlatformerDad88! This is a very common problem when following the Griffpatch tutorial. The issue is with duplicate movement code that conflicts with the collision detection system.
🔍 The Problem Explained
Here’s what’s happening in your collision system:
🛠️ The Solution
The move - in steps custom block is designed to replace the direct movement. You have both running at the same time!
Remove this conflicting code:
// ❌ REMOVE THIS - it bypasses collision detection change x by (speed x)
Keep only the safe movement system:
// ✅ KEEP THIS - proper collision detection move - in steps :: custom
🔧 Complete Movement System
Here’s how your movement code should look:
// Main movement loop when flag clicked forever // Handle input if <key [right arrow v] pressed?> then set [speed x v] to [5] else if <key [left arrow v] pressed?> then set [speed x v] to [-5] else set [speed x v] to [0] end end // Apply gravity change [speed y v] by [-1] // Move safely with collision detection move - in steps :: custom // Keep player on screen if <(x position) > [240]> then set x to [240] end if <(x position) < [-240]> then set x to [-240] end end
📋 Custom Block: move - in steps
Make sure your custom block looks like this:
define move - in steps // Move horizontally in small steps repeat (abs (speed x)) if <(speed x) > [0]> then change x by [1] else change x by [-1] end if <touching [walls v] ?> then if <(speed x) > [0]> then change x by [-1] else change x by [1] end set [speed x v] to [0] stop [this script v] end end // Move vertically in small steps repeat (abs (speed y)) if <(speed y) > [0]> then change y by [1] else change y by [-1] end if <touching [walls v] ?> then if <(speed y) > [0]> then change y by [-1] else change y by [1] end set [speed y v] to [0] stop [this script v] end end
🎯 Why This Works
- Step-by-step movement: Moves one pixel at a time to detect collisions precisely
- Immediate stopping: Stops movement the moment a wall is detected
- Position correction: Backs up one pixel when collision is detected
- Speed reset: Prevents momentum from carrying through walls
The key insight is that Griffpatch’s system replaces normal movement entirely - you can’t have both! 🎯
PlatformerDad88
Replied 15 hours later
@RokCoder_Expert YOU’RE A LIFESAVER! 🎉 We removed that extra change x by (speed x)
block and it works perfectly now!
My son is so excited that his character isn’t getting stuck anymore. Thank you so much for the detailed explanation - it really helped us understand what was going wrong! 🙌
GameTutor_Mike
Replied 3 hours later
Great solution! 🎮 This is actually one of the most common mistakes when following platformer tutorials. Here are some additional debugging tips:
🔍 Common Platformer Debugging Checklist
- Duplicate movement code: Make sure you only have ONE movement system
- Wall sprite setup: Ensure your walls sprite has the correct name and costumes
- Collision detection: Test with different wall shapes and sizes
- Speed values: Start with small speeds (3-5) for easier debugging
Pro tip: Always test your collision system with simple rectangular walls first before adding complex level designs! 🏗️
Vibelf_Community
Pinned Message • Moderator
🎮 Master Platformer Development
Excellent debugging work everyone! For those looking to create even more advanced platformers, our community can help with:
- 🏃 Advanced movement mechanics (wall jumping, dashing)
- 🎯 Precise collision detection systems
- 🌟 Special effects and animations
- 🏆 Level design best practices
📚 Related Tutorials
- Advanced collision detection techniques
- Creating smooth player movement
- Debugging common platformer issues
Ready to build amazing platformers? Get expert guidance from our tutors!