• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Jump problem

S

sulanum

Guest
Hello,

How can i fix this jump problem?


Sometimes, the player doesn't go back on the floor, but freeze above the floor.
Sometimes works it fine, and sometimes not.


This is my player :

I'm using this in the step event :

Collision:
- x = 0
- y = 1
- objects = only solid
- relative = checked/true

Gravity:
- direction = 270
- gravity = 1

--- else ----

Gravity:
- direction = 270
- gravity = 0

My jump script :



collision at a position:
- x = 0
- y = 1
- objects = only solid
- relative = checked/true

vertical speed :
- vrt. speed = -27

I tried multiple things, but it isn't working.
 
Last edited by a moderator:
M

Mordecai142

Guest
oh just noticed youre using gravity and stuff oops i probably cannot help
 
Last edited by a moderator:
P

ParodyKnaveBob

Guest
Howdy, sulanum, and welcome to GM and the GMC. $:^ ]

I'm about outta here, thus this'll be quick.

What does your collision with obj_gras look like? Could you post that, too?

Look up "solid" in the manual. It's probably shoving your player instance away from the ground. You likely need the action (in that collision event) to move the player instance to contact with the ground.

Just my guesses glancing at what you have here. I hope this helps,
Bob $:^ J
 
S

sulanum

Guest
Howdy, sulanum, and welcome to GM and the GMC. $:^ ]

I'm about outta here, thus this'll be quick.

What does your collision with obj_gras look like? Could you post that, too?
Thank you! :)

This is the obj_gras:

colission at position:
- x = 0
- y = 20
- objects = only solid
- relative = checked/true

move to contact:
- direction = direction
- maximum = -1
- against = solid objects

Vertical speed:
- vert. speed = 0
 
Last edited by a moderator:

Roderick

Member
Math!

You start with a vertical speed of -27. Your gravity is 1. So on the first step, you move up 27, then change your vertical speed to 26. The next step, you move up 26, and change vertical speed to 25, until you reach your apex. In the last step of upward movement, you move up 1, and set vertical speed to 0, and then you repeat all the steps in reverse.

If you are jumping on a perfectly even surface, everything should be ok. But if the ground where you land is one pixel higher, the code will go "Ok, move down 27, oh wait, that's blocked, just stop here, 26 pixels before the collision actually happens." If it's a pixel lower, you move down 27, then try to move down 28, collide, and stop 1 pixel too high, which causes more issues later.

If you weren't shutting off your gravity in the else branch, and instead set vertical speed to 0, when one of the above happened, you'd stop in midair, then start falling again, until the gap's smaller the movement, and it resets again. You'll hit the ground this way, but you'll get jerky stop and go falling for the last bit of the fall.

Also, I'm not super familiar with Drag and Drop, but I'm pretty sure your press space code should be
Code:
if
start block
commands
end block
else
start block
commands
end block
If you feel ready to start coding, I strongly recommend @ShaunJS's pixel-perfect platformer tutorial:
 
S

sulanum

Guest
If you weren't shutting off your gravity in the else branch
Didn't worked. I've changed the collision of the grass object and seems working fine now. :



I saw another problem, it is possible to jump on object which are not solid and invisible.
All objects doesn't have solid, only the obj_gras. i set all actions to only solid, so no idea how it is possible.
 
Last edited by a moderator:
S

sulanum

Guest
Did you watch the video I posted? It should answer all your questions and more.
Yes, but that doesn't help me.
I'm using drag and drop and i'm not using scripts for moving and jumping. GMS seems glitched, because everything seems good. The only problem is, that you can jump in the sky, if there is an (invisible) object with collision on false.
 
P

ParodyKnaveBob

Guest
Howdy again, sulanum,

I'm glad you're solving your problems! $:^ J

Also, I'm glad you waited at least two days before bumping your thread, but in the future, could you make a more informative post instead of "bump"? If nothing else, something like "I still haven't figured out why my non-solid invisible instances are acting like my solid obj_gras despite my using 'any' and not 'solid'..." just to point specifically at what you're waiting on if anyone's available.

But okay! That said, I might have a ridiculous solution for you:

I saw another problem, it is possible to jump on object which are not solid and invisible.
All objects doesn't have solid, only the obj_gras. i set all actions to only solid, so no idea how it is possible.
It has fortunately been discovered (due to people asking and answering questions on the GMC! $:^ ] ) that GM:Studio unfortunately has a bug with d'n'd actions using solid vs. any. Until YYG fixes it, I recommend you go ahead and use your actions, swap solid and any where need be, and leave a <!> comment action at EACH ONE reminding you to correct it later when YYG repairs GM's bug.

I hope this helps!
Bob $:^ J
 
Top