• 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!

GameMaker Physics + moving platform

P

ProjectGamesInc

Guest
Hi guys,

I have a game with physics, all setted and working well (room gravity, object phy properties and so on) but i have a small problem with a platform that basically goes up and down where you can jump on.
When the platform goes down the object above it keep "jumping", i think beacouse the gravity force is lower then the speed of the platform. (see the link below with the gif).

There is any way to fix that without going to change all the physics properties of the objects or the gravity? (since i worked a little bit to find the perfect settings for the game)

Thanks.

GIF of the problem : https://gifyu.com/image/TJdJ
 

Jezla

Member
How are you moving the platform? Post your code, please. It'll be easier to help you if we can see what you're doing.
 
P

ProjectGamesInc

Guest
No code at all, just using a path that move the platform from the 0,0 point to 0,-128 using path_start(path01, 2, path_action_reverse, 0)
The object is flagged as solid with 0 density while the ball still have density (actually 1.5 but i think its not important for what i want to do)
 
P

Pyxus

Guest
No code at all, just using a path that move the platform from the 0,0 point to 0,-128 using path_start(path01, 2, path_action_reverse, 0)
The object is flagged as solid with 0 density while the ball still have density (actually 1.5 but i think its not important for what i want to do)
The gif shows such a small area of the game, and that combined with the camera bounce and art style makes it difficult to see what's going on but I can take a guess. Typically what happens when people use gm physics and try to create an elevator is they accelerate the elevator too quick quickly down and the object on the elevator just enters free fall until either the object catches up or the elevator stops. What i'm seeing here is more like the object's momentum is being reset so even though the object catches up to the elevator its like it ignores gravity for a moment and re-enters free fall repeatedly. Anyway, I suspect that you may be changing either the lift or the player's, or both's, x and y position directly. However, when using gm physics you should refrain from doing that and instead use forces as it breaks the physics simulation. I think setting the phy_speed is also fine since a change in speed may be seen as a force internally anyway. So my question for you is are you doing 'x/y = something' at some point?
 

Jezla

Member
So my question for you is are you doing 'x/y = something' at some point?
The path is probably doing that, thus it's breaking the simulation. I ran into a similar problem in Cave Lander. @ProjectGamesInc , if your platform's motion is simply vertical, then set the phy_speed_y value to move it. I just did a quick test project where I set up a moving platform and a 'player' object to ride it, and I didn't have the bounciness on the way down. My player did get thrown upwards when my platform started to descend, but I was using abrupt speed changes, too.

One thing I have found, though in regards to GMS2 and physics. I get much better, and more consistent behavior if I define the world and all of my fixtures via code. Something doesn't seem to work quite right when I set the physics properties and fixtures via the object editor.

Bottom line: don't use a path, adjust the phy_speed_y (and/or _x) instead.
 
P

ProjectGamesInc

Guest
Thanks a lot to both of you, using the phy_speed did the trick! :)
 
  • Like
Reactions: jms
Top