Search Unity

Issues with the polygon collider 2D

Discussion in '2D' started by joxthebest314, Jun 20, 2020.

  1. joxthebest314

    joxthebest314

    Joined:
    Mar 31, 2020
    Posts:
    95
    So here is my problem : Sans titre.png
    The river is supposed to slow down the tank, but not when he is on the bridge. I thought I just had to create multiple polygon colliders on the river and just leave the area under the bridge collider-free, but apparently, I can't add more than one polygon collider.
    I know I could test if the player is on the bridge and then disable the river effect or something like that, but it seems a bit overkill for what it is. Have I missed a simple way to do it with colliders ?
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,459
    You can add as many colliders on a GameObject as you like.

    In the end, physics doesn't know about the logic of what should happen. It provides you with the ability to have collision response or, using triggers, detect collisions for your own logic. Whether you're in the river or on a bridge is down to your logic so the focus here on saying "do it with colliders" is a little confusing.

    Maybe you could ellaborate on what "do it with colliders" means to you if you don't want to use your own logic to determine if you're on the bridge or not.
     
    joxthebest314 likes this.
  3. joxthebest314

    joxthebest314

    Joined:
    Mar 31, 2020
    Posts:
    95
    Well, with more than one polygon collider on the object, the edit collider's shape button was disabled... Anyway I ended up creating multiple empty childs with each one it's own collider, but that doesn't seems really clean (but works).