Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Override collision of dynamic bodies

Discussion in 'Physics for ECS' started by jdtec, Mar 20, 2021.

  1. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    296
    Two dynamic bodies collide. I'd like one of the dynamic bodies to not move at all, sort of like having a kinematic/static (I think that's the right term?) collision response.

    Basically I want to be able to control which bodies can be pushed by others.

    What's the best way to do that?
     
    Last edited: Mar 20, 2021
  2. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    I would advise using PhysicsMassOverride component to control whether a body is dynamic or kinematic (or you could just set Motion type to Kinematic in Physics Body UI component. Please try it and let me know if that satisfies your needs. It's also useful to learn more about the use case, if you can share.
     
    jdtec likes this.
  3. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    You could also look at ModifyContactJacobiansBehaviour which shows how you can decide this pair-wise, making individual bodies act as if they have infinite mass/inertia against some other bodies. There is also a demo in Demos/5. Modify.
     
    jdtec likes this.
  4. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    296
    Thanks both. The ModifyContactJacobiansBehaviour idea sounds like it might work better as it will allow me to be more specific, whereas applying a kinematic tag to a body means that it will have kinematic reactions to all things (whilst the tag is added), which wasn't quite what I want.
     
    petarmHavok likes this.