Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Smooth velocity tutorial.
- coolboi1002
-
13 posts
Smooth velocity tutorial.
Want to make your sprite move smoothly? Well, this is the place for you!
- First, you want to make two variables: “X velocity” and "Y velocity.
- Then, make this script:
When green flag clicked,
set to
set to
forever
if <key right arrow pressed?> then
change by (1)
if <key left arrow pressed?> then
change by (-1)
if <key up arrow pressed?> then
change by (1)
if <key down arrow pressed?> then
change by (-1)
end
change x by (X velocity)
change Y by (Y velocity)
set to (X velocity) * (0.9)
set to (Y velocity) * (0.9)
Congrats, you have finished this tutorial!
- First, you want to make two variables: “X velocity” and "Y velocity.
- Then, make this script:
When green flag clicked,
set to
set to
forever
if <key right arrow pressed?> then
change by (1)
if <key left arrow pressed?> then
change by (-1)
if <key up arrow pressed?> then
change by (1)
if <key down arrow pressed?> then
change by (-1)
end
change x by (X velocity)
change Y by (Y velocity)
set to (X velocity) * (0.9)
set to (Y velocity) * (0.9)
Congrats, you have finished this tutorial!
Last edited by coolboi1002 (Jan. 30, 2024 19:21:31)
- Malicondi
-
1000+ posts
Smooth velocity tutorial.
using (x velocity) * (0.9) at the end is a little slippery like ice, i recommend using .8 or .85 Want to make your sprite move smoothly? Well, this is the place for you!
- First, you want to make two variables: “X velocity” and "Y velocity.
- Then, make this script:
When green flag clicked,
set to
set to
forever
if <key right arrow pressed?> then
change by (1)
if <key left arrow pressed?> then
change by (-1)
if <key up arrow pressed?> then
change by (1)
if <key down arrow pressed?> then
change by (-1)
end
change x by (X velocity)
change Y by (Y velocity)
set to (X velocity) * (0.9)
set to (Y velocity) * (0.9)
Congrats, you have finished this tutorial!
Last edited by Malicondi (Jan. 29, 2024 21:39:57)
- Discussion Forums
- » Help with Scripts
-
» Smooth velocity tutorial.