Search Unity

Moving platforms (2D) 2: electric boogaloo

Discussion in 'Physics' started by hyenabyte, Dec 19, 2018.

  1. hyenabyte

    hyenabyte

    Joined:
    Mar 5, 2017
    Posts:
    3
    Hello people

    I'm guessing moving platforms is a question that comes up a lot in here. In this case I haven't been able to come up with a suitable solution because of the way we use physics in our game.

    Edit: More specifically I need the player (or any physics-actor) to move with any moving platform and still preserve movement from input, which would be any other rigidbody (both kinematic, for scripted platforms, and dynamic for other characters or more complex platforms).


    Edit: Pictured is our current controller setup, a primary rigidbody with a capsule collider, and a foot in the form of a separate rigidbody with a circle collider, attached to the body with a sliderjoint with a motor strength so it will act like a spring.

    So the concept is that the characters rotation isn't locked and you are able to roll, and his rotation follows the terrain he stands on.

    I have seen solutions to moving platforms that involved using sliding joints and removing gravity. That won't work since the surface isn't completely flat. Another solution is to move the rigidbody, with the platform with MovePosition() or setting the velocity, but this didn't work either because we are moving the character with AddForce(), and if you constantly set velocity or position, any added force wont do anything.

    I was thinking that maybe creating sort of a "local space" for the platform would work, since the physics would function in the context of the platforms physics, but I have no idea how I would even begin to implement that.

    Here's a video that should give an idea of how movement is going to work


    Edit: I tried to put in some more info, since the original post was sort of lackluster. If you need more info don't hesitate to ask :)

    Edit2: I have been talking to some people about this, and they suggested I roll my own physics, which is probably what I am going to end up having to do.


    Any and all ideas are appreciated.

    Thanks,
    David
     
    Last edited: Jan 9, 2019