Search Unity

Sprite Shape 2D movement

Discussion in '2D' started by denwik, Apr 10, 2021.

  1. denwik

    denwik

    Joined:
    Sep 22, 2017
    Posts:
    27
    Well.. there is a lot of tutorials out there on Unitys Sprite shape-system. And it’s is a cool system.

    Using the edge collider it gives you a very nice collider to go with that. But I can’t find a good tutorial using the 2D physics engine to get a good working 2D platform movement going. Normaly, on flat ground, I whould do something like:
    rb.velocity = new Vector2(Input.GetAxis(”Horizontal) *speed, rb.velocity.y);

    But that won’t work very well on a curved collider. On an upwards slope the character presses against the collider so it loses velocity and if you release the input in a slope the character is forced up in the air by that previosly mentioned push into the collider. Meh..

    Any sugestions on how to deal with this? I have been able to solve the rotation of the character, rotating to the angle of the normal of the current collider-point. I think the only good way whould be to deactivate the RigidBody and somehow make the character follow the path och the curved collider during it’s stay on the curved surface. But I don’t know how.

    Thanks :)
     
  2. denwik

    denwik

    Joined:
    Sep 22, 2017
    Posts:
    27