Search Unity

Physic perfomance - isTrigger, Kinematic Rigibody vs Rigidbody Freeze

Discussion in 'Physics' started by Suduckgames, Jul 9, 2018.

  1. Suduckgames

    Suduckgames

    Joined:
    Nov 28, 2016
    Posts:
    218
    Hi, I am trying to figure out the pros/cons of using both approaches

    I have a typical space arcade where you have your ship and you kill the enemies that come with them

    I don't want the physic to drive any object since I am on the space and when "something" collide to "something" It just destroy the object and make some changes. I use it for shoots and drops (since they only need to advance in Z axis and make something when they enter in the trigger of the ship)

    So with that definition I should use RigidBody with "isKinematic" set to true, and "isTrigger" on the collider, however in the documentation about colliders it says

     Kinematic rigidbodies should be used for colliders that can be moved or disabled/enabled occasionally but that should otherwise behave like static colliders.


    So If I follow this line, the best approach should be to make the RigidBody "non-Kinematic" and just freeze the position and rotation on all axis, so I can just drive them by the transform component.

    In my understanding making a RigidBody non kinematic, allow the physic engine to check for the object (even when the rotation and position is freeze).

    So which one should I use and why? (From performance view)
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    That documentation is outdated. Using Kinematic bodies with non-trigger colliders is perfectly fine in your case IMHO.

    You need to enable the contact pairs in order to the collision events to be called (OnColliderEnter, etc). Edit > Project Settings > Physics:

    upload_2018-7-9_16-0-55.png

    Also, ensure to move your bodies via Rigidbody.MovePosition and Rigidbody.MoveRotation from FixedUpdate. Enable Interpolation in the bodies for smooth movement.