GMS 2 Physics + moving platform

Discussion in 'Programming' started by ProjectGamesInc, Dec 5, 2018.

  1. ProjectGamesInc

    ProjectGamesInc Member

    Joined:
    May 22, 2018
    Posts:
    45
    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
     
  2. Jezla

    Jezla Member

    Joined:
    Jun 20, 2016
    Posts:
    407
    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.
     
  3. ProjectGamesInc

    ProjectGamesInc Member

    Joined:
    May 22, 2018
    Posts:
    45
    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)
     
  4. Pyxus

    Pyxus Member

    Joined:
    Nov 6, 2016
    Posts:
    183
    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?
     
    ProjectGamesInc likes this.
  5. Jezla

    Jezla Member

    Joined:
    Jun 20, 2016
    Posts:
    407
    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.
     
    ProjectGamesInc and Pyxus like this.
  6. ProjectGamesInc

    ProjectGamesInc Member

    Joined:
    May 22, 2018
    Posts:
    45
    Thanks a lot to both of you, using the phy_speed did the trick! :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice