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

Disabling collider and setting RB to kinematic doesn't improve performance? (PhysicFixedUpdate)

Discussion in 'Physics' started by HSForge, Sep 2, 2018.

  1. HSForge

    HSForge

    Joined:
    May 22, 2017
    Posts:
    5
    In my game I have plenty of destructible objects (rocks, etc). Each object has a mesh collider, kinematic rigidbody, and simple script to store object's data (health, etc.). I have implemented an optimization mechanism by disabling distant object's collider, and only enable nearby ones. However, it doesn't improve the performance any tiny bit. In order to make any difference I have to disable the whole game object completely (which I hope it is not the only solution).

    It's not like I haven't searched/googled this problem yet, I have. Somewhere I read that setting rigidbody to kinematic will make the physic to ignore it completely. I haven't confirmed this yet. But based on this problem that statement might be not true (?).

    Here is a pic showing before and after I disabled all destructible objects:

    Before (objects are enabled):
    1.jpg

    After (objects are disabled):
    2.jpg

    So is there any other way to disable rigidbody? I mean other than setting it to kinematic since it doesn't seem to work. And preferably without having to remove the rigidbody component at all.

    I've had this problem for a long time actually, but only managed to make a thread about it now. I'd highly appreciate any help. Thanks in advance!
     
  2. StickyHoneybuns

    StickyHoneybuns

    Joined:
    Jan 16, 2018
    Posts:
    207
    The reason you aren't seeing any performance increase on just disabling some box colliders is because they aren't that performance heavy anyway, especially compared to everthing else. Why are you doing this anyway? Do you have performance issues? I assume all your collisions happen in fixedupdate which would make sense. Not having to calculate a large amount of collisions can save some performance.

    Setting a rigidbody to isKinematic will make it ignore all outside forces and you will have to control it by script.
    https://docs.unity3d.com/ScriptReference/Rigidbody-isKinematic.html

    So what exactly is your problem?