Open Forem

Cover image for 5 Ways to Make Your Scratch Sprite Move Smoothly (With Code Examples) Content
ItsMyBot
ItsMyBot

Posted on

5 Ways to Make Your Scratch Sprite Move Smoothly (With Code Examples) Content

The Problem

Most beginners start with this:

when [right arrow] key pressed
change x by (50)
Enter fullscreen mode Exit fullscreen mode

Result? Sprite teleports instead of moves. Not smooth at all.


Method 1: Forever Loop (Easiest Fix)

The golden rule: Check continuously, move in small steps.

when green flag clicked
forever
  if <key [right arrow] pressed?> then
    change x by (5)
  end
end
Enter fullscreen mode Exit fullscreen mode

Why it works:
✅ No keyboard repeat delay

✅ Checks 30 times/second

✅ Small steps = smooth motion

Use for: Player-controlled characters, responsive games


Method 2: Velocity + Friction (Professional Feel)

Add physics-like momentum:

when green flag clicked
set [x velocity] to (0)
forever
  // Acceleration
  if <key [right arrow] pressed?> then
    change [x velocity] by (1)
  end

  // Friction (gradual slowdown)
  set [x velocity] to ((x velocity) * (0.8))

  // Apply movement
  change x by (x velocity)
end
Enter fullscreen mode Exit fullscreen mode

Result: Sprite builds up speed and smoothly stops—feels like ice skating.

Use for: Platformers, racing games, anything needing momentum


Method 3: Smooth Gliding

For predetermined paths:

when green flag clicked
repeat until <(distance to [target]) < (5)>
  point towards [target]
  move ((distance to [target]) / (8)) steps
end
Enter fullscreen mode Exit fullscreen mode

Why divide by 8? Sprite moves 1/8 of remaining distance each frame = natural deceleration.

Use for: NPCs, cutscenes, click-to-move games


Method 4: Custom Block Movement

Reusable smooth movement:

define smooth move (direction) (speed)
if <(direction) = [right]> then
  change x by (speed)
end
// ... other directions

// Usage:
when green flag clicked
forever
  smooth move [right] (5)
  smooth move [left] (5)
end
Enter fullscreen mode Exit fullscreen mode

Use for: Multiple sprites with same movement logic


Method 5: Glide Block (Simplest)

when green flag clicked
glide (2) secs to x: (200) y: (100)
Enter fullscreen mode Exit fullscreen mode

Limitation: Can't interrupt easily, blocks other code.

Use for: Animations, linear paths


Common Mistakes to Avoid

❌ Adding wait blocks:

move (5) steps
wait (0.1) seconds // DON'T! Makes it choppy
Enter fullscreen mode Exit fullscreen mode

❌ Steps too large:

change x by (50) // Looks like teleporting
Enter fullscreen mode Exit fullscreen mode

✅ Keep steps between 2-10 pixels


Quick Comparison

Method Smoothness Difficulty Best For
Forever Loop ⭐⭐⭐⭐ Easy Player control
Velocity ⭐⭐⭐⭐⭐ Medium Professional games
Smooth Glide ⭐⭐⭐⭐⭐ Medium NPCs, AI
Custom Block ⭐⭐⭐⭐ Medium Reusability
Glide Block ⭐⭐⭐ Very Easy Simple animations

Complete Guide

For advanced techniques including:

  • Diagonal movement fix
  • Platformer physics
  • Mouse following
  • Camera systems
  • Collision handling

📚 Full Tutorial: How to Move Sprite Smoothly in Scratch

Your Turn

What movement method do you use? Drop your favorite technique in comments!

Pro tip: Combine velocity + friction for the most professional-feeling movement.


About ItsMyBot: We teach coding to kids aged 5-15 through project-based learning, turning screen time into skill time. Smooth movement is one of the first "aha!" moments students experience.

Top comments (0)