Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Rigidbody2D.Slide combined with Platformeffector

Discussion in 'Physics' started by marvin8121, Jan 22, 2024.

  1. marvin8121

    marvin8121

    Joined:
    Feb 8, 2023
    Posts:
    2
    I'm having troubles setting up a PlatformEffector2D on a BoxCollider while moving my object with Rigibody2d.Slide.

    I'm aiming to archive only having collision, when being the top of the collider.
    No matter what Surface Arc I choose, there is always collision on the sides of the platform.

    For reproducing on a simple enviroment I used the "Rigidbody2d_SlideMoveAlignAngle example from the Physics2d-Example Repository(https://github.com/Unity-Technologies/PhysicsExamples2D).

    Setting up the scene like this, the result will always be that the character stops at the selected collider. The goal is, that it would move through the collider, since it is coming from the side.
    upload_2024-1-22_12-37-57.png
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,652
    Slide doesn't interact with effectors that modify contacts such as the PlatformEffector2D, it's a method that uses physics queries, not simulation contacts to move.

    The PlatformEffector2D is for normal simulation work where a contact is created and the effector has the chance to disable a contact. Slide doesn't produce contacts nor does it have to run during the simulation step.
     
  3. marvin8121

    marvin8121

    Joined:
    Feb 8, 2023
    Posts:
    2
    Hey,
    thanks for the answer.
    So this basically means, I wont be able to use Slide to move through Colliders?
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,652
    To answer more directly, the options used to control what it can and cannot contact are contained here: https://docs.unity3d.com/2023.2/Documentation/ScriptReference/Rigidbody2D.SlideMovement.html

    Right now that's LayerMask only.

    That said, as part of the ongoing effort here, there was discussion to extend the options here to include a callback to user to allow you to control if it should contact something or not (called during a Slide operation).

    No actually implementation date or plan though, just something noted that would be a good extension to the options.