Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

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:
    88
    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:
    1,231
    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.