Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

2D collider mask

Discussion in '2D' started by RyFridge, Jun 18, 2015.

  1. RyFridge

    RyFridge

    Joined:
    Apr 7, 2014
    Posts:
    45
    Hey everyone,
    I have a seemingly complicated collider problem. Hope the figures below describe it well enough:

    collision01.jpg
    BLACK = Player, using Rigidbody2D and some kind of movement controller.
    RED = Different colliders, like platforms.
    YELLOW = Area in which the background collider should not apply, effectively somehow masking it.

    collision02.jpg
    Hitting PLAY: The player is falling down due to the laws of physics. The problem: He will bounce into the invisible background platform.

    collision03.jpg
    GREEN = Position where I'd like to have my block collide.

    So, I thought about a few approaches, but none seems to be the right way to do it:
    - Physics2D layers
    - RenderTexture for colorcheck
    - activating background collider on leaving the yellow box

    It must be scalable to like multiple (yellow) cells of different shapes and still work...

    Every idea is welcome! This must be solvable somehow?
    RyFridge
     
  2. RyFridge

    RyFridge

    Joined:
    Apr 7, 2014
    Posts:
    45
    Bumping, I hope it's okay.

    There must be someone here who has encountered such a problem? It seems like it would occur from time to time..

    Maybe I could like emulate a second layer of script generated edge colliders every frame? Is that viable?

    EDIT: If anyone is interested, I set this up for now, already mostly working. Next step is creating the PolygonCollider2D and the Plane (Mesh).

    ColliderTest.png
     
    Last edited: Jun 24, 2015
  3. abitofjohn

    abitofjohn

    Joined:
    Nov 6, 2012
    Posts:
    22
    This is exactly what I'm looking for, any tips for how you achieved this?

    Thanks