PHYSX 3.3 IN UNITY 5.6 & UNITY 2017.1 RIGIDBODY VS “STATIC” COLLIDERS…

I Googled and read numerous comments about colliders during runtime and their effects on performance. However I can’t seem to find a solid answer to my question.

Unity defines a Static Collider as;

“A Static Collider is just a gameobject with a collider component on it, but without a Rigidbody component.”

The question is “Should Static Colliders also have a Rigidbody attached for performance reasons?”.

I know that before Unity 5 Rigidbodies were required on all Static Colliders to prevent PhysX from recalculating the batched colliders.

Then in Unity 5 there was discussion of that no longer being the case; that in Unity 5 the Static Collider no longer required a Rigidbody, (for performance).

When looking at the documents for Collider (Unity 2017.1) it states

“If the object with the Collider needs to be moved during gameplay then you should also attach a Rigidbody component to the object. The Rigidbody can be set to be kinematic if you don’t want the object to have physical interaction with other objects.”

However in Mike Geig’s MerryFragmas 3.0 videos he states that the Rigidbody was a “remnant” – (6 minutes 32 seconds); making the Player Controller a Static Collider.

As I understand the Character_Controller component, it is a child of the Capsule Collider class, but I could be wrong on that.

Additionally Mike Geig added a second Collider to the Player Prefab in his training video.

Mike Geig’s comment is confirmed in the High Performance Physics in Unity 5 article;

“In Unity 5, we’ll use the same data structure to handle the movement of both dynamic and static colliders. Unfortunately, we’ll lose the benefit of Static Colliders consuming less memory than dynamic ones. However, right now, the cost associated with moving Static Colliders is one of the top 3 causes of performance issues in Unity games. We wanted to change that.”

So to set the record straight; will Colliders that are missing a Rigidbody component suffer from performance loss in Unity5 & Unity 2017?

“To Rigidbody or not to Rigidbody a Character Controller Component, that is my question.”

Thanks!

The simplest answer to your question is that if any of your object with a collider is moving then it or it’s parent should have a rigidbody and if they will not move in your game then there is no need for a rigidbody.

Actual explaination on this is that when you define a static collider without a rigidbody then Unity takes the collider position as a static one and do not recalculate the collider bounds every fixed frame. But if you start moving that object without a rigidbody then since there is no physics component(i.e. rigidbody in your case) Unity has to recalculate all the bounds again and again keeping the transform in mind.

One more explaination is that when you define a rigidbody Unity takes that object and it’s children into its physics pipeline and a dedicated script calculates all physics component’s bounds in fixed time but for any other moving static collider Unity has to calculate the bounds out of the box.

I hope I explained it properly.

There is no performance difference between moving a collider with or without a rigidbody component. That was fixed in Unity 5.

Now, there is a reason why you may still want to put kinematic rigidbodies on your colliders that will move. Currently, “static” colliders (those without a rigidbody) won’t wake up a rigidbody object that happenings to be sleeping on it.

So, for example, if you have a ball fall and land on a platform. Once the ball comes to a rest, it falls “asleep” due to physics inactivity (to be more efficient). If the platform has a “static” collider and it moves, the ball won’t wake up and thus won’t move or fall. If the platform were to also have a rigidbody, the ball would be woken up and resume physics simulation.

In summary, no performance issues but could lead to behavior issues with other objects.