Simulated = false vs isKinematic = true

So i have to temporaly disable physics for a GameObject, i’m curently setting “simulated” to false and then to true again and using “transform.position = xxx” to move it while is disabled, the question is, which is better for performance, this way or maybe with “isKinematic = true/false”, because both do the same for me in this situation.

Thanks!

Are you talking about 2D physics? You seem to be referring to Rigidbody2D.simulated but then you’re using “IsKinematic” which was replaced by BodyType.

Anyway, not having the Rigidbody2D and any attached colliders in the broadphase and all attached joints inactive will obviously give the best performance so setting Rigidbody2D.simulated to false is best.

It’s not clear why you think “IsKinematic” is performance related as it’s not. It just means it doesn’t respond to external forces. Attached colliders still get broadphase updates when it moves.

Without knowing if you’re doing this a few times hardly ever or 10,000 times a frame though; it’s hard to say. Only the profiler will tell you that.

1 Like

Sorry yes, i’m talking about RigidBody2D.simulated / RigidBody2D.isKinematic with a BoxCollider2D attached too.

I just need to continue triggering collisions with trigger colliders but ignore physical collisions during a process (going through a wall to be exact).

So currently i’m using “RigidBody2D.isKinematic = true” in the start of the process and “RigidBody2D.isKinematic = false” in the end of it, and it works like a charm, because setting simulated to false also ignores triggers and i need them to continue working, i was algo thinking to create a temporal layer to avoid non-wanted collisions but the “isKinematic” is doing the work well.

So i should be using RigidBody2D.bodyType? my editor says is read only, i have latest Unity version :confused:

Well yes, you’re taking it out of the simulation so that should be expected. It has zero impact then so no performance impact but if you still want the simulation then it’s of no use to you.

It can’t be read-only because IsKinematic just sets the body-type itself. You can see the script binding code here. It’s the way you set Static, Kinematic or Dynamic body-types.

1 Like

Thanks! seems that it was a fake alert of the editor once all the instruction is written its ok, thanks i changed “isKinematic” to “rigidbody2d.bodyType = RigidbodyType2D.Dynamic; / Kinematic”

Thanks so much!

1 Like