Discuss Scratch

_THEBOSS_
Scratcher
57 posts

how do i set a jump height limit??

when up key pressed in my platformer, the ball just keeps rising until i release the key .. help?
_THEBOSS_
Scratcher
57 posts

how do i set a jump height limit??

also… after awhile of sitting on the line, it drops suddenly through the line!! do i need to make the line thicker or create an overide variable?
deck26
Scratcher
1000+ posts

how do i set a jump height limit??

Is the project shared? The solution will depend on how you're handling the movement.
_THEBOSS_
Scratcher
57 posts

how do i set a jump height limit??

deck26
Scratcher
1000+ posts

how do i set a jump height limit??

Doesn't seem to be shared.
_THEBOSS_
Scratcher
57 posts

how do i set a jump height limit??

why do i have to share it? i linked it…
_THEBOSS_
Scratcher
57 posts

how do i set a jump height limit??

i just used the scratch wiki steps instead of sprites as platform, i used color green 38/100/100
deck26
Scratcher
1000+ posts

how do i set a jump height limit??

A link is no use if the project isn't shared!
_THEBOSS_
Scratcher
57 posts

how do i set a jump height limit??

how do you share… i have been using scratch for a few years but only now got an account sorry im new.
_THEBOSS_
Scratcher
57 posts

how do i set a jump height limit??

wait!!! it should be called 2020 pen platformer… make sure i did it right
Turtl3Man
Scratcher
4 posts

how do i set a jump height limit??

A good way to this is to make a velocity variable. For the velocity variable, any time you want to jump, increase your y velocity, which will then be going up if it is positive, by a number (typically 1, but it can be any number, as long as it is positive. the larger the number, the faster it will increase velocity. 9.8 will be the most accurate.), by setting y velocity to y velocity + x (your number of choice). Then, have it so once you reach a certain y height that you stop increasing y velocity, and start decreasing y velocity, by doing y velocity either - x or + -x.

This should all look something like this:

whenclicked
ifkey up arrow} pressed?> then repeatuntilyposition=200changeybyYVelocity+1elseforeverchangeybyYVelocity-1end
deck26
Scratcher
1000+ posts

how do i set a jump height limit??

I recommend you search in Scratch for ‘platformer tutorial’ and look at the one by @griffpatch-tutor which will take you through things step by step.

If your sprite is falling too fast it will go through platforms. Imagine it moves 10 pixels at a time and the platform is 5 pixels wide - there is a good chance it will just fall through.

Don't know how you managed it by you seem to have two custom blocks called ‘check ground touch’ which is just confusing. Try renaming one of them.

Wainggan
Scratcher
500+ posts

how do i set a jump height limit??

Turtl3Man wrote:

A good way to this is to make a velocity variable. For the velocity variable, any time you want to jump, increase your y velocity, which will then be going up if it is positive, by a number (typically 1, but it can be any number, as long as it is positive. the larger the number, the faster it will increase velocity. 9.8 will be the most accurate.), by setting y velocity to y velocity + x (your number of choice). Then, have it so once you reach a certain y height that you stop increasing y velocity, and start decreasing y velocity, by doing y velocity either - x or + -x.

This should all look something like this:

whenclicked
ifkey up arrow} pressed?> then repeatuntilyposition=200changeybyYVelocity+1elseforeverchangeybyYVelocity-1end
Problem: that will not work.

This could work though:

ifkeyuppressed?thensetyVto12 jump heightchangeybyyViftouchingground?thenchangeybyyV*-1setyVto0elsechangeyVby-1

Last edited by Wainggan (Nov. 22, 2019 17:43:02)

qucchia
Scratcher
100+ posts

how do i set a jump height limit??

Inside the Ball sprite, replace this
ifkeyup arrowpressed?orkeyspacepressed?thenifnottouchingcolor?thensetspeed yto15
with this
ifkeyup arrowpressed?orkeyspacepressed?thenchangeyby-1iftouchingcolor?thensetspeed yto15changeyby1
Some other things to do:
-You're changing the speed y variable by -1 in two forever loops, remove one to make it smoother.
-You should set the speed y variable to 0 when the ball touches the ground.

If you have any further questions or doubts, feel free to explain by responding below. I'm following this discussion so I'll get notified if anyone does. You can also create a new discussion if you think you should.
_THEBOSS_
Scratcher
57 posts

how do i set a jump height limit??

hey, some extra info… i´m not making my own physics, just copying ´advanced platformer physics´ in scratch wiki

thanks for the help, ill try the ideas ill respond again when i have thanks again!
_THEBOSS_
Scratcher
57 posts

how do i set a jump height limit??

ive tried all and none have worked!??? this is annoying… coped the griffpatch tutorial and still doesnt work!??
deck26
Scratcher
1000+ posts

how do i set a jump height limit??

It's much easier to help if you share a project that isn't working as you expect so we can see where you're going wrong. Is this your only shared project and is the non-working code in place? Removing code that doesn't work makes it harder for us to help.
qucchia
Scratcher
100+ posts

how do i set a jump height limit??

qucchia
Scratcher
100+ posts

how do i set a jump height limit??

_THEBOSS_ wrote:

ive tried all and none have worked!??? this is annoying… coped the griffpatch tutorial and still doesnt work!??
I used that in your project and it worked for me. Are you sure you copied it right?
_THEBOSS_
Scratcher
57 posts

how do i set a jump height limit??

i tried each and every one of the solutions… well i didn't put them in THIS script but in another… this is just the ‘advanced platformer physics’ in scratch wiki… i put each in… maybe i put them in the wrong spot but i doubt it

Powered by DjangoBB