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. Dismiss Notice

Dealing with a special case of collision

Discussion in '2D' started by Kottler, Feb 24, 2020.

  1. Kottler

    Kottler

    Joined:
    Mar 11, 2018
    Posts:
    12
    Hello, i'm doing a Breakout/Arkanoid clone to learn Unity2D and i have encountered a problem that i can't figure it out.

    So, i have a ball that bounces with walls, the racket and blocks and i'm working on a powerup that makes (for a few seconds) the ball to instantly destroy the blocks.

    The ball has a dmg, let's say 1 and blocks have 3 or more hp.
    When i get the powerup, the dmg of the ball is increased by a lot in order to destroy any kind of blocks. This is working fine.

    The problem starts with the collisions. I want the ball not to bounce on the blocks that it instantly destroy because that way the powerup makes no sense as it doesn't pierce through the blocks.

    I thought of disabling collision with those blocks for a period of time but the problem with this is that the blocks don't get damaged because they don't collide. I could make the ball a trigger but this makes the ball not to bounce on the walls and it goes out of the game.

    I also thought of having 2 colliders, one normal and the other one as trigger, and play around that, using the normal only for collision and the trigger for dmg and such. Also, disabling the normal one so it doesn't collide with the blocks and using the trigger to still do dmg.

    I don't know if that is a good idea or there is something simpler.
     
  2. ShiroTheWhite

    ShiroTheWhite

    Joined:
    Apr 4, 2018
    Posts:
    16
    You can do something like this


    Untitled.png
    Then when the Collider with trigger hits the wall and your max dmg is 3 or wall health - dmg you have now is zero then destroy the wall else do nothing until the other Normal collider hits. Triggers radius needs to be close enough to not look like it has the force
     
    Kottler likes this.
  3. Kottler

    Kottler

    Joined:
    Mar 11, 2018
    Posts:
    12
    Yes, i was thinking in something like this, thank you so much for the reply.