How to Move Sprite Smoothly in Scratch: Complete Beginner Guide

Reading Time: 12 mins

Scratch programming tutorial showing smooth sprite movement with code blocks and animated character demonstrating velocity-based motion control

Is your Scratch sprite moving in jerky steps instead of gliding smoothly? You’re not alone! This comprehensive guide shows you exactly how to move sprites smoothly in Scratch using proven techniques that create professional-looking animations and responsive game controls.


What Makes Sprite Movement Look Smooth in Scratch?

Smooth movement in Scratch happens when sprites transition between positions without visible jumps or stutters. The secret isn’t just one techniqueβ€”it’s understanding three key factors:

The smooth movement formula:

  1. Frame rate – How often the sprite updates position
  2. Step size – How many pixels to move each update
  3. Velocity control – How speed changes over time

Why it matters: Smooth movement makes games feel professional, animations look polished, and interactive projects more engaging for players.


Quick Comparison: Smooth vs Jerky Movement

Jerky Movement (What NOT to do)

when [right arrow] key pressed
change x by (50)

Problem: Sprite teleports 50 pixels each key press

Smooth Movement (What TO do)

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

Why it works: Continuous checking + smaller steps = smooth motion


Method 1: Forever Loop Movement (Best for Beginners)

This is the most reliable method for smooth sprite movement in Scratch.

Basic Smooth Movement Code

Step 1: Create the forever loop

when green flag clicked
forever
  if <key [right arrow] pressed?> then
    change x by (5)
  end
  if <key [left arrow] pressed?> then
    change x by (-5)
  end
  if <key [up arrow] pressed?> then
    change y by (5)
  end
  if <key [down arrow] pressed?> then
    change y by (-5)
  end
end

Why this works:

  • βœ… Continuously checks for key presses
  • βœ… No keyboard repeat delay
  • βœ… Small step size (5 pixels) creates smooth motion
  • βœ… Works in all four directions

Pro tip: The forever loop runs approximately 30 times per second in Scratch, giving you naturally smooth updates.


Method 2: Glide Block Movement (Best for Animations)

The glide block creates automatic smooth movement between two points.

Basic Glide Usage

when green flag clicked
glide (2) secs to x: (200) y: (100)

Perfect for:

  • Cutscenes and animations
  • Predetermined paths
  • Intro/outro sequences
  • NPC movement patterns

Limitations:

  • Can’t interrupt mid-glide easily
  • Not ideal for player-controlled movement
  • Blocks other code until complete

Advanced Glide with User Control

when this sprite clicked
glide (1) secs to x: (mouse x) y: (mouse y)

Use case: Click-to-move games where the sprite walks to where you click.


Method 3: Velocity-Based Movement (Professional Quality)

This creates momentum, acceleration, and decelerationβ€”the technique used in professional games.

Setting Up Velocity Variables

Step 1: Create variables

  • x velocity (for horizontal movement)
  • y velocity (for vertical movement)

Step 2: Set initial values

when green flag clicked
set [x velocity] to (0)
set [y velocity] to (0)

Horizontal Velocity Movement

when green flag clicked
forever
  // Acceleration
  if <key [right arrow] pressed?> then
    change [x velocity] by (2)
  end
  if <key [left arrow] pressed?> then
    change [x velocity] by (-2)
  end
  
  // Apply friction/deceleration
  set [x velocity] to ((x velocity) * (0.8))
  
  // Move the sprite
  change x by (x velocity)
end

What each part does:

  • Acceleration: Pressing arrow increases velocity
  • Friction: Multiplying by 0.8 gradually slows down
  • Movement: Velocity changes position each frame

Result: Sprite builds up speed when you press keys and smoothly stops when releasedβ€”just like real physics!


Method 4: Custom Block Smooth Movement (Advanced)

Create reusable smooth movement code with custom blocks.

Creating the Custom Block

Step 1: Make a Block

  • Go to My Blocks
  • Click β€œMake a Block”
  • Name it β€œsmooth move”
  • Add inputs: key (text), speed (number)
  • Enable β€œRun without screen refresh”

Step 2: Define the Block

define smooth move (key) (speed)
if <key (key) pressed?> then
  if <(key) = [right]> then
    change x by (speed)
  end
  if <(key) = [left]> then
    change x by ((0) - (speed))
  end
  if <(key) = [up]> then
    change y by (speed)
  end
  if <(key) = [down]> then
    change y by ((0) - (speed))
  end
end

Step 3: Use the Block

when green flag clicked
forever
  smooth move [right] (5)
  smooth move [left] (5)
  smooth move [up] (5)
  smooth move [down] (5)
end

Advantages:

  • Cleaner, organized code
  • Easy to adjust speed in one place
  • Reusable across multiple sprites

Method 5: Smooth Gliding with Distance Formula

Create movement that slows down as it approaches the destinationβ€”perfect for realistic animations.

The Smooth Glide Code

when green flag clicked
repeat until <(round (distance to [mouse-pointer])) = (0)>
  point towards [mouse-pointer]
  move ((distance to [mouse-pointer]) / (8)) steps
end
go to [mouse-pointer]

How it works:

  • Dividing distance by 8 means sprite moves 1/8 of remaining distance each frame
  • As sprite gets closer, steps get smaller
  • Creates natural deceleration effect

Result: Sprite appears to β€œease” into its destination rather than stopping abruptly.


Fixing Common Smooth Movement Problems

Problem 1: Sprite Moves Too Fast

Symptoms: Can’t control sprite, moves across screen instantly.

Solution: Reduce step size

// Too fast
change x by (20)

// Better
change x by (5)

// Even smoother
change x by (2)

Rule of thumb: Start with 3-5 pixels per step, adjust based on your game.


Problem 2: Sprite Moves in Steps/Jumps

Symptoms: Visible β€œteleporting” between positions.

Cause: Using key press events instead of forever loop.

Wrong way:

when [right arrow] key pressed
move (10) steps

Right way:

when green flag clicked
forever
  if <key [right arrow] pressed?> then
    move (10) steps
  end
end

Why the difference: when key pressed waits for keyboard repeat delay. Forever loop checks continuously.


Problem 3: Diagonal Movement Too Fast

Symptoms: Moving diagonally (pressing two arrow keys) makes sprite move faster than horizontally/vertically.

Cause: Adding both X and Y velocity without normalizing.

Solution: Limit maximum velocity

when green flag clicked
forever
  // Movement input
  if <key [right arrow] pressed?> then
    change [x velocity] by (1)
  end
  if <key [up arrow] pressed?> then
    change [y velocity] by (1)
  end
  
  // Limit speed
  if <(x velocity) > [5]> then
    set [x velocity] to (5)
  end
  if <(y velocity) > [5]> then
    set [y velocity] to (5)
  end
  
  // Apply movement
  change x by (x velocity)
  change y by (y velocity)
  
  // Friction
  set [x velocity] to ((x velocity) * (0.9))
  set [y velocity] to ((y velocity) * (0.9))
end

Problem 4: Movement Feels Unresponsive

Symptoms: Delay between pressing key and sprite moving.

Causes:

  1. Using glide for player control (blocks other code)
  2. Adding unnecessary wait blocks
  3. Keyboard repeat rate (system setting)

Solution: Use forever loop method

when green flag clicked
forever
  // NO wait blocks here!
  if <key [right arrow] pressed?> then
    change x by (5)
  end
end

Problem 5: Sprite Rotates When Moving

Symptoms: Sprite flips upside down or rotates unexpectedly.

Cause: Using move block with wrong rotation style.

Solution: Set rotation style

when green flag clicked
set rotation style [left-right] // or [don't rotate]
forever
  if <key [right arrow] pressed?> then
    move (5) steps
  end
end

Rotation styles:

  • All around: Sprite rotates fully (0-360Β°)
  • Left-right: Sprite only faces left or right
  • Don’t rotate: Sprite never rotates

Adding Smooth Animation to Movement

Make your sprite walk, run, or animate while moving smoothly.

Basic Animation While Moving

when green flag clicked
forever
  if <key [right arrow] pressed?> then
    change x by (5)
    next costume
    wait (0.1) seconds
  end
end

Pro tip: Your sprite should have multiple costumes showing different walk/run frames.

Advanced Animation with Speed

when green flag clicked
set [animation timer] to (0)
forever
  if <key [right arrow] pressed?> then
    change x by (5)
    change [animation timer] by (1)
    if <(animation timer) > [5]> then
      next costume
      set [animation timer] to (0)
    end
  end
end

Why this works: Animation only updates every 5 frames, creating controlled walk cycle regardless of movement speed.


Smooth Movement for Different Game Types

Platformer Games

Features needed:

  • Left/right horizontal movement
  • Gravity
  • Jumping
  • Momentum

Code example:

when green flag clicked
set [y velocity] to (0)
set [x velocity] to (0)
forever
  // Horizontal movement
  if <key [right arrow] pressed?> then
    change [x velocity] by (1)
  end
  if <key [left arrow] pressed?> then
    change [x velocity] by (-1)
  end
  
  // Apply horizontal velocity
  set [x velocity] to ((x velocity) * (0.8))
  change x by (x velocity)
  
  // Gravity
  change [y velocity] by (-1)
  change y by (y velocity)
  
  // Ground collision (simplified)
  if <touching [ground]?> then
    set [y velocity] to (0)
    // Allow jumping
    if <key [space] pressed?> then
      set [y velocity] to (15)
    end
  end
end

Top-Down Adventure Games

Features needed:

  • 4-directional movement
  • Collision detection
  • Speed consistency

Code example:

when green flag clicked
forever
  // Store old position
  set [old x] to (x position)
  set [old y] to (y position)
  
  // Movement
  if <key [right arrow] pressed?> then
    change x by (4)
  end
  if <key [left arrow] pressed?> then
    change x by (-4)
  end
  if <key [up arrow] pressed?> then
    change y by (4)
  end
  if <key [down arrow] pressed?> then
    change y by (-4)
  end
  
  // Collision response
  if <touching [wall]?> then
    go to x: (old x) y: (old y)
  end
end

Racing/Driving Games

Features needed:

  • Forward/backward acceleration
  • Turning/steering
  • Speed limits
  • Momentum

Code example:

when green flag clicked
set [speed] to (0)
set [direction] to (0)
forever
  // Acceleration
  if <key [up arrow] pressed?> then
    change [speed] by (0.5)
  end
  if <key [down arrow] pressed?> then
    change [speed] by (-0.5)
  end
  
  // Speed limits
  if <(speed) > [10]> then
    set [speed] to (10)
  end
  if <(speed) < [-5]> then
    set [speed] to (-5)
  end
  
  // Steering (only when moving)
  if <key [right arrow] pressed?> then
    change [direction] by ((speed) / (2))
  end
  if <key [left arrow] pressed?> then
    change [direction] by ((0) - ((speed) / (2)))
  end
  
  // Apply movement
  point in direction (direction)
  move (speed) steps
  
  // Friction
  set [speed] to ((speed) * (0.95))
end

Mouse-Following Smooth Movement

Make sprites smoothly follow the mouse cursor.

Basic Mouse Follow

when green flag clicked
forever
  point towards [mouse-pointer]
  move (5) steps
end

Problem: Sprite never stops, orbits around mouse.

Smooth Mouse Follow with Stop

when green flag clicked
forever
  if <(distance to [mouse-pointer]) > [10]> then
    point towards [mouse-pointer]
    move ((distance to [mouse-pointer]) / (10)) steps
  end
end

Why it works:

  • Only moves when distance > 10 pixels
  • Speed proportional to distance
  • Naturally decelerates as it approaches

Optimization Tips for Smooth Movement

Tip 1: Use β€œRun Without Screen Refresh”

For custom blocks handling movement:

βœ… Enable "Run without screen refresh"

Why: Prevents screen flicker, increases performance.


Tip 2: Minimize Blocks in Forever Loop

Less efficient:

forever
  // 20 different if statements checking everything
end

More efficient:

forever
  check movement :: custom // Handle in custom block
  check collisions :: custom // Separate custom block
end

Tip 3: Use Variables for Constants

// Create variable "move speed" set to 5
when green flag clicked
set [move speed] to (5)
forever
  if <key [right arrow] pressed?> then
    change x by (move speed)
  end
end

Benefit: Easy to adjust speed in one place, experiment with values.


Testing Smooth Movement

Checklist for Smooth Sprite Movement

☐ Visual smoothness

  • [ ] No visible jumps or teleporting
  • [ ] Consistent speed across screen
  • [ ] Smooth acceleration/deceleration

☐ Responsiveness

  • [ ] Immediate response to key press
  • [ ] No input delay
  • [ ] Works at 30 FPS (Scratch standard)

☐ Control feel

  • [ ] Easy to stop exactly where intended
  • [ ] Predictable movement direction
  • [ ] Comfortable speed for gameplay

☐ Technical performance

  • [ ] No lag or stuttering
  • [ ] Works with multiple sprites moving
  • [ ] Consistent across different devices

Common Mistakes to Avoid

Mistake 1: Using Wait Blocks in Movement Code

Don’t do this:

forever
  if <key [right arrow] pressed?> then
    move (5) steps
    wait (0.1) seconds // DON'T!
  end
end

Why: Creates choppy movement, introduces delay.


Mistake 2: Not Using Forever Loops

Don’t do this:

when [right arrow] key pressed
move (10) steps

Do this:

when green flag clicked
forever
  if <key [right arrow] pressed?> then
    move (10) steps
  end
end

Mistake 3: Step Size Too Large

Don’t do this:

change x by (50) // Too much!

Do this:

change x by (5) // Smooth!

Rule: Keep steps between 2-10 pixels for most games.


Mistake 4: Forgetting Friction/Deceleration

Without friction:

if <key [right arrow] pressed?> then
  change [x velocity] by (1)
end
change x by (x velocity)
// Sprite never stops!

With friction:

if <key [right arrow] pressed?> then
  change [x velocity] by (1)
end
set [x velocity] to ((x velocity) * (0.8))
change x by (x velocity)
// Sprite gradually stops

Advanced Technique: Smooth Camera Follow

Make the view follow the player smoothly (creates camera effect).

Basic Setup

Requirements:

  • Player sprite
  • Background sprite (large scrolling background)

Player stays centered, background moves:

// Player sprite
when green flag clicked
forever
  if <key [right arrow] pressed?> then
    broadcast [scroll right]
  end
  if <key [left arrow] pressed?> then
    broadcast [scroll left]
  end
end

// Background sprite
when I receive [scroll right]
change x by (-5)

when I receive [scroll left]
change x by (5)

Result: Player appears to move through world as background scrolls.


Smooth Movement with WASD Keys

Alternative control scheme for games.

when green flag clicked
forever
  // Right (D key)
  if <key [d] pressed?> then
    change x by (5)
  end
  
  // Left (A key)
  if <key [a] pressed?> then
    change x by (-5)
  end
  
  // Up (W key)
  if <key [w] pressed?> then
    change y by (5)
  end
  
  // Down (S key)
  if <key [s] pressed?> then
    change y by (-5)
  end
end

Why offer WASD: Many players prefer it, especially in action games.


Troubleshooting Guide

Issue: Sprite Stutters Even with Forever Loop

Possible causes:

  1. Too many sprites moving simultaneously
  2. Complex collision detection in same loop
  3. Heavy graphics/effects

Solutions:

// Separate movement from heavy calculations
when green flag clicked
forever
  handle movement :: custom
end

when green flag clicked
forever
  check collisions :: custom
  wait (0.1) seconds // Reduce collision check frequency
end

Issue: Sprite Moves Through Walls

Problem: Smooth movement but no collision response.

Solution: Check collision AFTER movement, revert if touching

forever
  set [old x] to (x position)
  set [old y] to (y position)
  
  // Movement code here
  
  if <touching [wall]?> then
    go to x: (old x) y: (old y)
  end
end

Real Project Example: Smooth Platformer Character

Complete code for professional-feeling character movement.

// Variables needed:
// x velocity, y velocity, on ground

when green flag clicked
set [x velocity] to (0)
set [y velocity] to (0)
forever
  // Horizontal input
  if <key [right arrow] pressed?> then
    change [x velocity] by (1)
  end
  if <key [left arrow] pressed?> then
    change [x velocity] by (-1)
  end
  
  // Speed limit
  if <(x velocity) > [8]> then
    set [x velocity] to (8)
  end
  if <(x velocity) < [-8]> then
    set [x velocity] to (-8)
  end
  
  // Apply horizontal movement
  change x by (x velocity)
  
  // Horizontal collision
  if <touching [wall]?> then
    change x by ((0) - (x velocity))
    set [x velocity] to (0)
  end
  
  // Friction
  set [x velocity] to ((x velocity) * (0.85))
  
  // Gravity
  change [y velocity] by (-1)
  
  // Apply vertical movement
  change y by (y velocity)
  
  // Ground collision
  if <touching [ground]?> then
    set [y velocity] to (0)
    set [on ground] to [true]
  else
    set [on ground] to [false]
  end
  
  // Jumping
  if <<key [space] pressed?> and <(on ground) = [true]>> then
    set [y velocity] to (12)
  end
end

Features:

  • βœ… Smooth acceleration and deceleration
  • βœ… Speed limits prevent too-fast movement
  • βœ… Proper collision response
  • βœ… Physics-based jumping
  • βœ… Can only jump when on ground

Key Takeaways: Mastering Smooth Sprite Movement

Essential principles:

  1. Use forever loops – Continuous checking creates smooth motion
  2. Keep steps small – 2-10 pixels per update looks smooth
  3. Add velocity/momentum – Professional games feel better with physics
  4. Include friction – Sprites should gradually stop, not instantly
  5. Test across devices – Movement should feel good everywhere

The smooth movement formula:

Forever loop + Small steps + Velocity + Friction = Smooth movement

Common methods ranked:

  1. Best overall: Velocity-based with friction (most professional)
  2. Easiest: Forever loop with direct position changes
  3. For animations: Glide blocks
  4. Most flexible: Custom blocks with parameters

Continue learning:

For young learners: At ItsMyBot, we teach these concepts through engaging, project-based courses designed for kids aged 5-15. Smooth movement is just the beginningβ€”we progress to advanced game mechanics, animations, and eventually text-based programming.


Next Steps in Your Scratch Journey

Now that you know how to move sprites smoothly, try building:

Beginner projects:

  • Simple maze game with smooth controls
  • Character that follows mouse smoothly
  • Car racing game with acceleration

Intermediate projects:

  • Platformer with jumping and gravity
  • Top-down adventure with collision
  • Space shooter with momentum

Advanced projects:

  • Physics-based puzzle game
  • Complex character with multiple movement states
  • Multiplayer game with smooth network sync

Ready to master Scratch and beyond?

At ItsMyBot, we turn screen time into skill time through personalized, industry-level courses. From Scratch basics to Python, JavaScript, and roboticsβ€”we help kids aged 5-15 build real skills through hands-on creation.
πŸ’‘ More free tutorials: itsmybot.com/blog
πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦ For parents: Track progress and stay involved every step of the way

Tags

Share

Poornima Sasidharan​

An accomplished Academic Director, seasoned Content Specialist, and passionate STEM enthusiast, I specialize in creating engaging and impactful educational content. With a focus on fostering dynamic learning environments, I cater to both students and educators. My teaching philosophy is grounded in a deep understanding of child psychology, allowing me to craft instructional strategies that align with the latest pedagogical trends.

As a proponent of fun-based learning, I aim to inspire creativity and curiosity in students. My background in Project Management and technical leadership further enhances my ability to lead and execute seamless educational initiatives.

Related posts