Search Unity

Got moving platforms? How is your collision/movement set up?

Discussion in '2D' started by Marscaleb, Mar 31, 2019.

  1. Marscaleb

    Marscaleb

    Joined:
    Jan 7, 2014
    Posts:
    1,037
    One of the major problems I have always had with my game is moving platforms. No matter how I've set them up, I run into some kind of problem. When the player stands on them, he lags behind the movement for nearly half a second. I tried a different method, and then the player moved with the platform, but if the player tried to walk their movement to the platform was barely a crawl. I've had problems with platforms moving down that the player has to "fall" on to repeatedly, and just, well, all kinds of things messing up.

    Well I'm about to start work on completely overhauling my game's movement/collision system. One of the biggest things on my agenda is to fix these problems with moving platforms.

    Since I'm making such a dramatic overhaul, I'd like some ideas on how I should set it up.
    So I'm curious how other people have set up their games.

    How do you have your player move and collide with the world? How do you have the player check for where the ground is? How do you have the platform's movement affect the player?


    As for myself, I originally set the player up to use three points on the bottom of the player which check for overlapping circles (with the radius set very very small) to see if there is viable ground there. This of course is used to determine if the player should be falling. I calculate the player's gravity in their movement code because the default physics didn't feel right, and so I manually adjusted how the player "falls." The X movement was calculated simply by the player input, although possibly it was stopped by other factors in the game logic. Each update I calculated all of the player's movement and applied it in a vector that was used as the player's velocity for that update, which I believe was applied to a rigidbody. (I'll check some of these details when I get home in a couple hours.)

    I recall hearing from some people that they used a vector operation of some kind to calculate the distance from the player's feet to the ground. I'm curious how that worked out and what kind of advantages it offered.
    But overall, I just want to hear about other methods that could be used to properly handle the player's movement and such. What kind of method do you use?