1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GM:S 1.4 Moving PlatForm Vertical

Discussion in 'Programming' started by ragingdemonz, Jun 28, 2016.

  1. ragingdemonz

    ragingdemonz Member

    Joined:
    Jun 28, 2016
    Posts:
    287
    Hi i seem to be having an issue with the moving platform, the way i was doing my Horizontal ones was using

    y+=pvspd
    x+=phspd

    //if on top
    if place_meeting(x,y+1,MovF)
    {
    pvspd=instance_nearest(x,y,MovF).vspeed;
    phspd=instance_nearest(x,y,MovF).hspeed;
    }
    it works for the most part when hes standing on top of it and its going up.
    however it seems when the platform reaches to the top where the speed reverser is, when it goes down, the player does not smoothly transition with the Moving floor, instead he plays the falling animation and falls down with the gravity. Is there a way to keep him on top of the platform without him falling?
     
  2. jo-thijs

    jo-thijs Member

    Joined:
    Jun 20, 2016
    Posts:
    2,844
    Hi and welcome to the GMC!

    Moving platforms can be a finicky thing in GameMaker.

    First of all, I would recommend not using instance_nearest in the code you've provided,
    but rather use instance_place (which still isn't perfect, but is much better though).

    Secondly, I think your code will still work with vertical platforms if you time things correctly.

    The order in which things have to happen is:
    1) Platforms decide in which direction and at what speed they will be moving this step.
    2) The player performs his movements as though platforms are not moving.
    3) The player verifies if he is standing on the platform (or pushed from the side?).
    4) If the player touches a platform, he will move the same amount as the platforms will move
    (can cause problems if multiple platforms touch the player or if the player gets pushed to a wall by a moving platform)
    5) The moving platforms move.

    Do things work out better when they are performed in this order?
    If not, could you perhaps upload the gmz file of your project somewhere,
    so that I can take a look at it and mess around with moving platforms myself?
    Out of experience I know they can be hard to get done right from the first time,
    especially if you can't test their behaviour yourself.

    Could you also give every situation in which moving platforms could appear?
    (can they push the player against a wall?)
    (can they crush the player?)
    (can they get clode to each other?)
    (can they overlap with certain objects?)
    (do they always go in one of 4 directions?)
    (...)
     
    Snail Man likes this.
  3. RangerX

    RangerX Member

    Joined:
    Jun 20, 2016
    Posts:
    2,602
    Something I do in my game is that I move my character by hspeed and vspeed and the platform moves it by X and Y positions. This way nothing interferes.
     
  4. ragingdemonz

    ragingdemonz Member

    Joined:
    Jun 28, 2016
    Posts:
    287
    @jo-thijs , the file is really huge contains to much to send a gmz over the problem only happens when the moving floor switches its vspeed, so when it reaches the top and it starts going back down, the player does not move down with it, instead the player falls first before landing back on it and then preceding to move down with it.

    @RangerX - I'm not sure what you mean, are you saying you move your character based solely on the built in movement variables?

    i've also tried just making it work the opposite way in which the code is in the Moving floor itself rather then the character.

    it seems to somewhat work except the player is constantly in the jumping state and just bouncing up and down by a pixel or 2 and other times it just bugs up and prevents the block from ever moving upwards.

    if place_meeting(x,y-1,player)player.pvspd=vspeed}
     
  5. Snail Man

    Snail Man Member

    Joined:
    Jun 20, 2016
    Posts:
    282
    Try putting that line of code you posted only in the event where the moving platform changes vertical direction, so after the rest of the code in the collision with speed reverser event
     
  6. ragingdemonz

    ragingdemonz Member

    Joined:
    Jun 28, 2016
    Posts:
    287
    @Snail Man
    i just ended up doing this, it seems the work a bit better as he doesn't just "Fall" anymore, but now the problem is happening when its going upwards,he will playing his jumping animation and for some reason the vspeed seems to act up as well

    i did what you told me and i placed it in the step event of the Moving object
    if place_meeting(x,y-10,player){player.y+=vspeed}
     
  7. Snail Man

    Snail Man Member

    Joined:
    Jun 20, 2016
    Posts:
    282
    Did you try putting it in the platform's collision with reverser event, but removing it from the step event as well?
     
  8. ragingdemonz

    ragingdemonz Member

    Joined:
    Jun 28, 2016
    Posts:
    287
    yes nothing seems to be working :/ , i'm not entirely sure why it would work for gm8.1 and not for GMS... there arent any insane calculations for this
     
  9. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,960
    I personally have vertical platforms check for contact with players (and other moveable things, if any). If there are any, those are moved before the platform is moved. From the perspective of the player, all platforms are stationary, which makes the player's code easier to manage than if adapting to moving platforms was the player's duty. Also, if you use the built-in collision system, I strongly recommend against having moving platforms use hspeed/vspeed - it doesn't end well. x3 (You'll have to compensate for how GM treats collisions and solid objects a lot, and avoiding that altogether easily ends up as the most simple solution).

    I guess I should also take this opportunity to plug my general-purpose platform engine, MariaEngine. It has horizontal, vertical and path-based moving platforms (and a ton of other stuff): https://yaru.itch.io/mariaengine
     
  10. ragingdemonz

    ragingdemonz Member

    Joined:
    Jun 28, 2016
    Posts:
    287
    I seemed to have fix it by changing the variables a bit , thank you all for the help!
     

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