Fixing lag in Griffpatch platformer tutorial part 1
این محتوا هنوز به زبان شما در دسترس نیست.
💡 Having trouble with Scratch block assembly? Don’t know how to implement code logic? 🚀 Get Help Now
PlatformGamer_Pro
Posted on July 22, 2025 • Intermediate
🎮 Griffpatch platformer tutorial suddenly super laggy!
I’m following the amazing @griffpatch platformer tutorial and everything was going perfectly until I got to part 1 with the collision detection for the x-axis. 😫
Now my game is incredibly laggy - the character moves super slowly, jumping barely works half the time, and I can visually see the lag happening. It’s definitely not my computer because other projects run fine.
I think it might be something with my collision detection scripts, but I can’t figure out what’s wrong. The tutorial was working perfectly before I added that part!
Has anyone else run into this issue? I’m really stuck and would love some help debugging this! 🙏
PlatformerTutor_Sam
Replied 4 hours later • ⭐ Best Answer
@PlatformGamer_Pro I know exactly what’s happening! This is a super common issue with the Griffpatch tutorial. The problem is with how you’re using the movement custom block. 🎯
🐛 The Problem: Inefficient Movement Loop
You’re probably calling the movement block like this, which creates a massive performance bottleneck:
// WRONG - This causes lag! Move - In Steps (speed y)
When speed y
is a large negative number (like -15 when falling), Scratch tries to repeat the movement 15 times every frame. That’s what’s killing your performance!
✅ The Solution: Use Absolute Value
Here’s the fix that Griffpatch explains later in the tutorial:
// CORRECT - This fixes the lag! Move - In Steps ([abs v] of (speed y))
🔧 Why This Works
Here’s what’s happening behind the scenes:
🚀 Complete Movement System Fix
Here’s how your movement custom block should look:
define Move - In Steps (steps) repeat (steps) if <(direction) = [1]> then change x by [1] else change x by [-1] end // Check for collision after each step if <touching [Platforms v]?> then if <(direction) = [1]> then change x by [-1] else change x by [1] end stop [this script v] end end
And call it like this:
// For horizontal movement if <(speed x) > [0]> then set [direction v] to [1] Move - In Steps ([abs v] of (speed x)) else set [direction v] to [-1] Move - In Steps ([abs v] of (speed x)) end // For vertical movement if <(speed y) > [0]> then set [direction v] to [1] Move - In Steps ([abs v] of (speed y)) else set [direction v] to [-1] Move - In Steps ([abs v] of (speed y)) end
💡 Pro Tips for Better Performance
- Always use absolute values for step counts in movement blocks
- Limit collision checks - don’t check every single pixel if you don’t need to
- Use efficient collision sprites - simple rectangles work better than complex shapes
- Consider step size - moving 2-3 pixels per step instead of 1 can improve performance
This should completely fix your lag issue! The tutorial continues to explain this concept in more detail. Keep following along - Griffpatch’s tutorials are absolutely fantastic once you get past this common stumbling block! 🎮
PlatformGamer_Pro
Replied 20 minutes later
@PlatformerTutor_Sam OH MY GOODNESS! 🤯 That was exactly it!
I changed it to use the absolute value and the lag is completely gone! My character is moving smoothly again and jumping works perfectly!
I can’t believe such a small change made such a huge difference. Thank you so much for the detailed explanation - now I understand WHY it was lagging! 🙌
Time to continue with the tutorial! 😄
GriffpatchFan_Alex
Replied 1 hour later
This is such a classic mistake! 😅 I remember making the exact same error when I first followed the tutorial.
@PlatformerTutor_Sam’s explanation is spot-on. The absolute value fix is mentioned in the tutorial, but it’s easy to miss if you’re coding along quickly.
Pro tip: Always watch the entire tutorial section before coding. Griffpatch often explains the “why” after showing the “how”! 🎯
Vibelf_Community
Pinned Message • Moderator
🎮 Master Platformer Development
Great problem-solving! For those working on advanced platformers, our tutors can help you with:
- ⚡ Performance optimization techniques
- 🎯 Advanced collision detection
- 🏃 Smooth character movement
- 🎨 Visual effects and polish
- 🏆 Level design principles
📚 Related Topics
- Optimizing Scratch game performance
- Advanced collision detection methods
- Following coding tutorials effectively
Stuck on a tutorial or need help optimizing your platformer? Our expert tutors are here to help you succeed!