Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Tell me how i can make my character dash through hazards and walls without going through the floor o

Discussion in '2D' started by BluejayGameDev, Jun 20, 2022.

  1. BluejayGameDev

    BluejayGameDev

    Joined:
    Jun 20, 2022
    Posts:
    3
    Hey, i am making a 2dd game, I've created a dash effect. I've been trying to get the player to dash through objects by disabling the boxcollider, but it just goes through the floor. Does anyone know a way to fix this?
     
  2. Rin-Dev

    Rin-Dev

    Joined:
    Jun 24, 2014
    Posts:
    558
    One way is using layers. For example, have a "Phantom Player" layer. Edit this layer in the physics settings to not collide with Wall or Object layers but collide with ground layers. When you dash, change your players layer to Phantom Player, change back when dash is done.

    I can already see the bugs happening from this though. Imagine dashing through an object but you don't go through it all the way before switching back. Tons of physics weird happenings.

    That's how I handled jumping through the floors at first in my own game while testing.
     
  3. BluejayGameDev

    BluejayGameDev

    Joined:
    Jun 20, 2022
    Posts:
    3
    @Rin-Dev Thank you, ill see if i can do that. Do u know any tutorials that go through that? Im new to coding.
     
  4. Rin-Dev

    Rin-Dev

    Joined:
    Jun 24, 2014
    Posts:
    558
    Not off the top of my head. Try googling "Unity Layers Physics" and looking around.
     
  5. BluejayGameDev

    BluejayGameDev

    Joined:
    Jun 20, 2022
    Posts:
    3
    Rin-Dev likes this.