Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Smooth rotation
- HappyKid54321
-
100+ posts
Smooth rotation
So I'm making a sprite where it spins around when left and right arrow keys are pressed. So i'm using this code:
So I need a smooth version of what code is on top.
Thanks so much if you can find this out
when [Left arrow v] key pressedand,
turn ccw (3) degrees
when [Right arrow v] key pressedBut when I use it, there is like a 0.25 second delay between each time it rotates.
turn cw (3) degrees
So I need a smooth version of what code is on top.
Thanks so much if you can find this out

- knightjj11
-
100+ posts
Smooth rotation
If you're experiencing a delay between each rotation when using the arrow keys in Scratch, it might be due to the default “key repeats” settings in the Scratch editor. Fortunately, you can adjust these settings to achieve smoother rotations.
Here's how you can make it smoother:
Click on the “Stage” to select it.
Look for the “Stage” backdrop's code area.
Add the following code:
This code continuously checks if the left or right arrow key is pressed and then turns the sprite accordingly. By placing this code in the backdrop, you avoid the default key repeat settings and can achieve smoother rotations.
Now, when you press and hold the left or right arrow key, the sprite should smoothly rotate without the delay you experienced before. Adjust the degree values if you want a faster or slower rotation speed.
- Jason a.k.a Knightjj11
Here's how you can make it smoother:
Click on the “Stage” to select it.
Look for the “Stage” backdrop's code area.
Add the following code:
when green flag clicked
forever
if <key [put whatever here] pressed?> then
turn ccw (3) degrees
end
end
This code continuously checks if the left or right arrow key is pressed and then turns the sprite accordingly. By placing this code in the backdrop, you avoid the default key repeat settings and can achieve smoother rotations.
Now, when you press and hold the left or right arrow key, the sprite should smoothly rotate without the delay you experienced before. Adjust the degree values if you want a faster or slower rotation speed.
- Jason a.k.a Knightjj11
- RokCoder
-
1000+ posts
Smooth rotation
The answer above is partially right but also quite confusing.
When you press a key and hold it down there is a slight delay before the key repeats. You can see this when typing a comment into the forum. It's the default behaviour for a computer keyboard. This is what you see when using the when (any) key pressed blocks. If you want to react smoothly to key presses without this initial pause after the first press, use the key (any) pressed? blocks as described above. Don't use them in the stage though - use them in the sprite that is reacting to the key presses.
When you press a key and hold it down there is a slight delay before the key repeats. You can see this when typing a comment into the forum. It's the default behaviour for a computer keyboard. This is what you see when using the when (any) key pressed blocks. If you want to react smoothly to key presses without this initial pause after the first press, use the key (any) pressed? blocks as described above. Don't use them in the stage though - use them in the sprite that is reacting to the key presses.
- alebro6DW
-
100+ posts
Smooth rotation
Motion blocks don't work in the stage. If you're experiencing a delay between each rotation when using the arrow keys in Scratch, it might be due to the default “key repeats” settings in the Scratch editor. Fortunately, you can adjust these settings to achieve smoother rotations.
Here's how you can make it smoother:
Click on the “Stage” to select it.
Look for the “Stage” backdrop's code area.
Add the following code:when green flag clicked
forever
if <key [put whatever here] pressed?> then
turn ccw (3) degrees
end
end
This code continuously checks if the left or right arrow key is pressed and then turns the sprite accordingly. By placing this code in the backdrop, you avoid the default key repeat settings and can achieve smoother rotations.
Now, when you press and hold the left or right arrow key, the sprite should smoothly rotate without the delay you experienced before. Adjust the degree values if you want a faster or slower rotation speed.
- Jason a.k.a Knightjj11
- Ereasercollector2
-
7 posts
Smooth rotation
Could this help?
Hope it helps!
when green flag clicked
reset timer
point in direction (90)
forever
repeat (Put whatever here)
turn cw ([sin v] of (timer)::operators) degrees
end
wait (0.5) secs
reset timer
repeat (Put whatever here)
turn ccw ([sin v] of (timer )::operators) degrees
end
wait (0.5) secs
reset timer
end
Hope it helps!

Last edited by Ereasercollector2 (Jan. 3, 2025 13:59:15)
- Ereasercollector2
-
7 posts
Smooth rotation
Could this help?when green flag clicked
reset timer
point in direction (90)
forever
repeat (Put whatever here)
turn cw ([sin v] of (timer)::operators) degrees
end
wait (0.5) secs
reset timer
repeat (Put whatever here)
turn ccw ([sin v] of (timer )::operators) degrees
end
wait (0.5) secs
reset timer
end
Hope it helps!
- Discussion Forums
- » Help with Scripts
-
» Smooth rotation