Search Unity

One way moving platform with Platform Effector 2D

Discussion in '2D' started by Mangas, Nov 12, 2015.

  1. Mangas

    Mangas

    Joined:
    Jan 16, 2013
    Posts:
    17
    I have a Platform Effector 2D assigned to a BoxCollider2D in a moving platform with One Way activated with 1 degree for the Arc so only collisions from above the platform causes the player to collide. The player has a CircleCollider2D and a not kinematic RigidBody2D.

    Almost everything works fine, I can jump from below, wait for a platform to pick me up or pass through from the sides.

    But I have two problems with the effector, the first one, when the platform goes down and I'm in between the platform and the ground, instead of passing through me the effector pulls me to the top of the platform when it goes just under the center of the player collider. And when jumping it seems that the effector gives me a little boost to the jump as I end higher than with a normal jump, even if the platform is static and not moving.

    I've searched for any bugs in my end, but I just can't find it, these two bugs doesn't trigger the collisions I code for the moving platform nor grounded events for the player.

    Someone knows what might be happening here? Are the Platform Effectors not meant to be used on moving platforms? :/
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    When you say 'moving' the platform, do you mean re-positioning the GameObject that the effector/collider is on via the Transform? If so, when you re-position an object (it's not moving under physics) then all contacts are recalculated. If you re-position in such a way that the collision normal equates to hitting the surface then it'll cause a collision; if its overlapped then the physics system will solve the overlap by moving stuff.

    Also, if the platform is moving, I presume you've got a kinematic rigid-body on it else it's static and should not be moved.

    It's possible for the physics system to try to correlate a previously disabled contact with the new one (after you re-position) but doing that is fraught with problems; it might not always be appropriate. I've took note of this and will see what can potentially be done there.

    When you move physics objects though, move a rigid-body via velocity if possible.