Search Unity

  1. Unity 2019.1 beta is now available.
    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. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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:
    110
    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,337
    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.