Search Unity

PlatformEffector2D behaving strangely when GameObject contains multiple colliders

Discussion in 'Physics' started by Abhinav91, Nov 2, 2015.

  1. Abhinav91

    Abhinav91

    Joined:
    Oct 21, 2013
    Posts:
    67
    Hey everyone. So I'm not sure if this is a bug or something that I am doing wrong. I felt a video would be best to demonstrate the issue. I'm using Unity 5.2.



    Basically I have a 'player' GameObject with BoxCollider2D and CircleCollider2D components attached. The slope is a GameObejct with an Edge Collider and the platform on the right is a GameObject with a BoxCollider2D. The slope and the platform both have PlatformEffector2D components attached to them.

    As you can see in the video, once the player walks off the edge of the slope, rather than fall through, his BoxCollider2D gets caught in the platform. As a result the CircleCollider2D is through the platform, but the BoxCollider2D is still colliding with the platform. As long as I continue going in the same direction, the behavior continues, but when I change direction, the CircleCollier2D now goes to the top of the platform. The change of direction is done by changing the eulerAngle on the Y axis, if that information is relevant. I was assuming that because there are 2 colliders attached to the player, the calculations would be different.

    Is this a bug or am I doing something wrong here?
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    The video says "The uploader has not made this video available".

    I'm guessing that the PlatformEffector2D is set to allow things to enter from the sides/bottom but not from the top and that when moving from that sloped edge into the box, the circle enters from the edge and never goes above the top so it never collides however, the box does go above the edge and then tries to move through the top which causes a collision.

    Currently, the PlatformEffector2D works on individual colliders and calculates each ones contacts. This can be problematic with characters composed of multiple colliders.

    It's not a bug but to be honest, it's a design oversight on my part and it's something I'm looking into.

    The current way I want to solve this is to add a new behaviour option in the PlatformEffector2D that propagates a disabled contact on a collider to all other colliders on the same Rigidbody2D or more specifically, it needs to ensure that any future contacts on other colliders are also disabled.
     
    Last edited: Nov 3, 2015
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    Your post kicked me into action!

    The PlatformEffector2D now supports one-way grouping so that all colliders act as one when using the one-way behaviour.



    I'll get this into the release stream ASAP.
     
  4. Abhinav91

    Abhinav91

    Joined:
    Oct 21, 2013
    Posts:
    67
    Sorry about the video. In an effort to not monetize the video, I ended up blocking it in all countries. Fixed it shortly after reading your post.

    Wow! That's great news! Appreciate it!
    Looking forward to the next release.