Search Unity

Question Bounciness effect on character

Discussion in 'Physics' started by PasTime_Paragon, Nov 12, 2023.

  1. PasTime_Paragon

    PasTime_Paragon

    Joined:
    Dec 22, 2022
    Posts:
    5
    I am working on a 2D platformer game, and I want to make an object that bounces off of other objects but does not bounce the character when he touches it. I just used the bounciness property, and it currently has the physics I want, but the bounciness also has an undesired effect on the player. This is probably kind of basic, but is there a trick to make something like the bounciness property of a material exclusively effect or not effect certain items.

    I'm guessing this could be done using tags, but I don't know how to mess with the properties in a way that would do that.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,419
    It's not basic at all and contacts between objects don't have any "direction" to them beyond logically in your head.

    I don't see how tags would help even if you used them in a Collision callback because the callback happens after the response has happened; it's there to tell you it's occurred.

    So, with that said, I introduced a feature in 2022.2 that allows you to control force send/receive layers per-collider so when a contact happens, normally an impulse is applied to both objects; this allows you to control that.

    You can see it in the post here: https://forum.unity.com/threads/2d-physics-in-unity-2022-2.1363719/

    https://docs.unity3d.com/2022.2/Documentation/ScriptReference/Collider2D-forceSendLayers.html
    https://docs.unity3d.com/2022.2/Documentation/ScriptReference/Collider2D-forceReceiveLayers.html