Search Unity

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

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

  1. Kazeon

    Kazeon

    Joined:
    May 22, 2017
    Posts:
    41
    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?