Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Platform Effector 2D Side Friction

Discussion in 'Unity 5 Pre-order Beta' started by The_BenEvans, Feb 17, 2015.

  1. The_BenEvans

    The_BenEvans

    Joined:
    Jul 31, 2012
    Posts:
    139
    Hi,

    We're making a 2D game where the player is constantly moving right and jumping on 1D platforms.

    There's always been an issue of colliding with the "corner" of the Edge Collider 2D causing the player to get stuck. I was hoping the Platform Effector 2D would solve this in Unity 5, am I missing something or is it not a feature?

    Current Setup:
    Platform GameObject
    -Edge Collider 2D
    =Material - Assigned to custom physic material
    =Used by Effector = true
    -Platform Effector 2D
    =Collider Mask - Player and Default assigned
    =One way = true
    =Side Friction = false
    =Side Bounce = false
    =Side Angle Variance = 0
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,459
    Yes, the platform effector will zero the friction of the contact automatically for you when in contact with the 'side' however it'll only help if it's friction that is causing the player to get stuck. Beyond that, it's hard to say.
     
  3. The_BenEvans

    The_BenEvans

    Joined:
    Jul 31, 2012
    Posts:
    139
    Thanks for the reply. So that only affects the friction and not the collision itself?

    I should probably have mentioned these are very simple, 2 point, horizontal Edge Colliders which are static. The Player has a constant velocity moving right.
    I was hoping to only allow collisions if the player was coming from directly above the platform and treat "side" collisions as if the player was coming from underneath (don't collide).

    I've managed a workaround for now, but interested to know if such functionality existed in the component?
    Cheers
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,459
    The most direct answer I can give is that when Box2D detects any contact for non-triggers (Sensors in Box2D speak) then it calculates the friction to be applied. The PlatformEffector2D intercepts this contact and if it determines that you've hit the platform side then it zeros this friction and it stays at zero. It does not modify velocities so if you're constantly pushing (adding a force) to keep something in contact with a 'side' then it'll continue to be in contact with it if gravity (or any other force) can't pull it down.

    As to 'side' collisions and 'one-way'; it looks at relative vertical velocity (and other details) to determine if it should pass through or not. If you are moving (relative) sideways with no vertical velocity then it'll contact as this is a side collision.

    If you can break your problem down into a simple reproducible scene and submit it as a tentative bug case (pass me the case number) then I'm more than willing to take a look at it for you.
     
  5. The_BenEvans

    The_BenEvans

    Joined:
    Jul 31, 2012
    Posts:
    139
    Ok, thanks again!