Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I make my character jump smoothly until it reaches a certain y pos?
- MapleTree_
-
Scratcher
6 posts
How do I make my character jump smoothly until it reaches a certain y pos?
I'm making a platformer, I've made the jumping code, but my old code:
made it so that when my character jumped off a platform, the character landed on the same y pos as the platform. So I made a NEW code so that it would be able to stop jumping at a certain y pos:
But as you can guess, it wasn't that smooth. So I have to ask:
How do I make my character jump smoothly until it reaches a certain y pos?
repeat (10)
change y by (10)
end
repeat (10)
change y by (-10)
end
made it so that when my character jumped off a platform, the character landed on the same y pos as the platform. So I made a NEW code so that it would be able to stop jumping at a certain y pos:
repeat (10)
change y by (10)
end
repeat until <touching color [#08d046] ?>
change y by (-1)
end
But as you can guess, it wasn't that smooth. So I have to ask:
How do I make my character jump smoothly until it reaches a certain y pos?
Last edited by MapleTree_ (Jan. 6, 2021 18:27:04)
- ScratchCatHELLO
-
Scratcher
1000+ posts
How do I make my character jump smoothly until it reaches a certain y pos?
You should try using
Also, this belongs in Help with Scripts, not Questions about Scratch. Requesting to be moved.
<(y position) = [123]> //replace 123 with the y pos that you want it to stop at.Instead of
<touching color [#0a77e3] ?>
Also, this belongs in Help with Scripts, not Questions about Scratch. Requesting to be moved.
- MapleTree_
-
Scratcher
6 posts
How do I make my character jump smoothly until it reaches a certain y pos?
You should try usingBut ScratchCatHELLO, I need a way to calculate how much my character should move downwards. I can repost in Help with Scripts btw.<(y position) = [123]> //replace 123 with the y pos that you want it to stop at.Instead of<touching color [#0a77e3] ?>
Also, this belongs in Help with Scripts, not Questions about Scratch. Requesting to be moved.
- xXRedTheCoderXx
-
Scratcher
1000+ posts
How do I make my character jump smoothly until it reaches a certain y pos?
Try this:
Try messing around with the values to see what's best for your game. Maybe set Y velocity to 3, or 10 insead of 5. Or try having the Y velocity change by -3 or -5 instead of -1. Hope this helped.
if <touching color [#08d046]?> then
set [Y velocity v] to [5]
change y by (Y velocity)
repeat until <touching color [#08d046]?>
change [Y velocity v] by (-1)
change y by (Y velocity)
end
end
Try messing around with the values to see what's best for your game. Maybe set Y velocity to 3, or 10 insead of 5. Or try having the Y velocity change by -3 or -5 instead of -1. Hope this helped.

- portalpower
-
Scratcher
1000+ posts
How do I make my character jump smoothly until it reaches a certain y pos?
set [+y v] to (height)
repeat (height)
change y by (+y)
change [+y v] by (-1)
end
repeat until <touching color [#00ff00] ?>
change y by (+y)
change [+y v] by (-1)
end
- MapleTree_
-
Scratcher
6 posts
How do I make my character jump smoothly until it reaches a certain y pos?
Try this:I don't use velocity in my game doe…if <touching color [#08d046]?> then
set [Y velocity v] to [5]
change y by (Y velocity)
repeat until <touching color [#08d046]?>
change [Y velocity v] by (-1)
change y by (Y velocity)
end
end
Try messing around with the values to see what's best for your game. Maybe set Y velocity to 3, or 10 insead of 5. Or try having the Y velocity change by -3 or -5 instead of -1. Hope this helped.
- Klicky_Kitty
-
Scratcher
40 posts
How do I make my character jump smoothly until it reaches a certain y pos?
You should use velocity. If you don’t, then stick to the not smooth thing. It’s much glitchier and the variable helps a lot.Try this:I don't use velocity in my game doe…if <touching color [#08d046]?> then
set [Y velocity v] to [5]
change y by (Y velocity)
repeat until <touching color [#08d046]?>
change [Y velocity v] by (-1)
change y by (Y velocity)
end
end
Try messing around with the values to see what's best for your game. Maybe set Y velocity to 3, or 10 insead of 5. Or try having the Y velocity change by -3 or -5 instead of -1. Hope this helped.
- thesuperfuncoder
-
Scratcher
77 posts
How do I make my character jump smoothly until it reaches a certain y pos?
, also that should be if not touching color greenTry this:I don't use velocity in my game doe…if <touching color [#08d046]?> then
set [Y velocity v] to [5]
change y by (Y velocity)
repeat until <touching color [#08d046]?>
change [Y velocity v] by (-1)
change y by (Y velocity)
end
end
Try messing around with the values to see what's best for your game. Maybe set Y velocity to 3, or 10 insead of 5. Or try having the Y velocity change by -3 or -5 instead of -1. Hope this helped.
Last edited by thesuperfuncoder (Jan. 7, 2021 02:34:06)
- keywastaken
-
New Scratcher
3 posts
How do I make my character jump smoothly until it reaches a certain y pos?
Try this:if <touching color [#08d046]?> then
set [Y velocity v] to [5]
change y by (Y velocity)
repeat until <touching color [#08d046]?>
change [Y velocity v] by (-1)
change y by (Y velocity)
end
end
Try messing around with the values to see what's best for your game. Maybe set Y velocity to 3, or 10 insead of 5. Or try having the Y velocity change by -3 or -5 instead of -1. Hope this helped.
Sorry for necroposting, but how do I get my player character to jump while moving? When I pressed the jump button and the arrow keys at the same time, it just stopped and then jumped, then resumed moving. How do I fix this?
Last edited by keywastaken (Dec. 15, 2022 15:45:46)
- Discussion Forums
- » Help with Scripts
-
» How do I make my character jump smoothly until it reaches a certain y pos?

