Search Unity

Dodge Roll

Discussion in '2D' started by elgatodorado, Aug 17, 2019.

  1. elgatodorado

    elgatodorado

    Joined:
    Apr 7, 2019
    Posts:
    22
    I'm making a platformer 2d game and I couldn't find how to do a dodge roll that can cross enemies.

    Can someone give an example? Or if you know a tutorial can you share it to me?

    All tutorials I could find explain how to do a dodge roll but not how to avoid collision with enemies with the dodge.

    Thank you for your time.
     
  2. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    771
    Simply disable the player character's collider at the beginning of the roll and enable it again at the end of the roll.

    To prevent the character from falling through the world, don't use the same collider for colliding with terrain and enemies.
    Use two separate colliders and have them collide with different layers: one for terrain, and one for enemies.