Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Making A Sprite Jump Smoothly
- _The_Artist_
-
Scratcher
28 posts
Making A Sprite Jump Smoothly
Hi! I'm making a platformer for the first time, and I'm trying to make my sprite jump smoothly. I've looked at different forums and stuff, but I'm having a hard time making my sprite jump diagonally and smooth. I don't really want to take anything from anyone's project. Any code that might help? I want to keep it simple. Thanks!
- mstone326
-
Scratcher
1000+ posts
Making A Sprite Jump Smoothly
THis is a good place to start. It covers everything for a platformer. Just take your time going through it. Otherwise, we'll have to see what you have so far and try to adapt a jump script for you.
https://scratch.mit.edu/projects/67727504/
Edit:
I had a simple jump project in my forum help studio but best to follow the above tutorial I linked.
https://scratch.mit.edu/projects/150519918/
https://scratch.mit.edu/projects/67727504/
Edit:
I had a simple jump project in my forum help studio but best to follow the above tutorial I linked.
https://scratch.mit.edu/projects/150519918/
Last edited by mstone326 (Jan. 2, 2018 01:56:11)
- elias_the_dank
-
New Scratcher
9 posts
Making A Sprite Jump Smoothly
Here is a script that will make your sprite jump smoothly:
…rather than just doing this:
…which does not work well AT ALL. Hope this helps! Can't wait to see your project!
when green flag clicked
set [jump height v] to [15] // Change this value depending on how high you want the sprite to jump
forever
if <key [space v] pressed?> then
set [jump velocity v] to (jump height)
repeat until <(jump velocity) = [0]>
change y by (jump velocity)
change [jump velocity v] by (-1)
end
repeat until <(jump velocity) = (join [-] (jump height))>
change [jump velocity v] by (-1)
change y by (jump velocity)
end
end
end
…rather than just doing this:
when green flag clicked
forever
if <key [space v] pressed?> then
glide (.5) secs to x: (x position) y: ((y position) + (15))
glide (.5) secs to x: (x position) y: ((y position) - (15))
end
end
…which does not work well AT ALL. Hope this helps! Can't wait to see your project!

- _The_Artist_
-
Scratcher
28 posts
Making A Sprite Jump Smoothly
Here is a script that will make your sprite jump smoothly:Thanks! I may use this in the future, but for right now I'm trying to keep the code fairly simple.when green flag clicked
set [jump height v] to [15] // Change this value depending on how high you want the sprite to jump
forever
if <key [space v] pressed?> then
set [jump velocity v] to (jump height)
repeat until <(jump velocity) = [0]>
change y by (jump velocity)
change [jump velocity v] by (-1)
end
repeat until <(jump velocity) = (join [-] (jump height))>
change [jump velocity v] by (-1)
change y by (jump velocity)
end
end
end
…rather than just doing this:when green flag clicked
forever
if <key [space v] pressed?> then
glide (.5) secs to x: (x position) y: ((y position) + (15))
glide (.5) secs to x: (x position) y: ((y position) - (15))
end
end
…which does not work well AT ALL. Hope this helps! Can't wait to see your project!

- saodtheking
-
Scratcher
100+ posts
Making A Sprite Jump Smoothly
This is the simplest way i can think of
when [space v] key pressed
set [y velocity v] to [15]
if (touching [Ground v]) then
change y by (y velocity)
repeat until (touching [Ground v])
change y by (y velocity)
change [y velocity v] by [-1]
end
set [y velocity v] to ((y velocity) * (-1))
change y by (y velocity)
end
- Miner3141
-
Scratcher
56 posts
Making A Sprite Jump Smoothly
Hi! I'm making a platformer for the first time, and I'm trying to make my sprite jump smoothly.
when green flag clickedIf your head hits ground, you fall back down. If your feet hit ground, you stop jumping
set [power v] to (5)
repeat (20)
change y by (power)
change [power v] by (-0.5)
if <touching [ground]>
if <(power) > [0]>
set [power v] to ((0) - (power))
repeat until <(power) = [0]>
change y by (power)
change [power v] by (-0.5)
end
else
stop [this script v]
end
end
end
optional for enemies that detect jumping:
broadcast [jumped v]
Last edited by Miner3141 (Jan. 3, 2018 17:56:14)
- Discussion Forums
- » Help with Scripts
-
» Making A Sprite Jump Smoothly




