Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Do moving entities with the Collider Monobehavior need the Rigidbody Monobehavior before conversion?

Discussion in 'Physics for ECS' started by Abbrew, Jan 23, 2020.

  1. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    Back then GameObjects with colliders needed a rigidbody. Otherwise, all colliders in the scene would be recalculated every time one of the rigidbody-less GameObjects move. Is this still true for ECS Physics?
     
  2. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    If a Rigid Body (or new Physics Body Authoring) component is not added, then a rigid body is still created on entity conversion but it will be static in the simulation. This is the same scenario for GameObject where only a Collider component is added.
    I'm not quite sure what you mean by 'recalculated every time one of the rigidbody-less GameObjects move'.
    If a supposedly static body is re-positioned then the physics simulation needs to completely update the broadphase.
    If no static bodies have moved, the simulation will only need to update the part of the boardphase handling the dynamic bodies.
    If you think that a body is going to be moved around, then you should add a Rigid Body (or Physics Body) component and mark it as Kinematic (i.e dynamic with an infinite mass). This will add it to the dynamic tree but it will still not be affected by other bodies bouncing of it.

    Can I ask about the context behind your question? Are you wanting to move static objects around frequently? If so, are they very large?
     
    Abbrew likes this.
  3. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    Thank you for your response. I have a few soldier entities that need collision detection. The soldiers will move around often. Based on your info those soldiers should have a RigidBody Monobehavior attached, but with Kinematic checked. This way they can participate in collision detection without forcing a broadphase recalculation every time they move. Is this correct?