- Home /
Multiple Colliders Performance
Hi,
i have a Character controller on my GameObject. There is another primitive collider as child object on empty gameObject. This child collider serves as collision detection where i find out if other gameObject hits this GameObject.
Thing is, that if i use this child collider to detect collision wiht other objects with Character controller, the performance goes down like 10 fps on Iphone from 30 to 20. I realy dont know what is the issue. Since there is nothing unusual about the way i set up the colliders.
So what i was thinking is, if the issue can be the character controller capsule is intersecting with the child box colllider ? Or if this big fps drop can be caused by several colission detections when these objects are spawned ?
Also what would be the best solution for selective collisions. Lets say i would like to use these child colliders only to collide with one give object ? I know about the ignore collissions. But it didnt seem to work properly.
Thanks for any help.
Answer by dannyskim · Jan 24, 2012 at 11:36 PM
Character Controllers by default are 4 to 8 times more expensive than a regular rigid body with a collider. This is a fairly wide known fact, and it's suggested to avoid Character Controllers as much as possible when deploying to mobile platforms. There is just a lot of default built-in overhead to Character Controllers that you most likely will not need.
Hard coding your own functions with a Capsule Collider that mimics the same functions as a Character Controller is much more efficient.
When you add a child collider to an object, it inherits the physics layer information from the parent, there is no way of going around this. So, because of this, no, your two colliders are not colliding with each other.
For selective collisions on the same moving body, it's easiest to create separate objects that are not in the same hierarchy, and have them just follow the position of the object that you're wanting to follow by script only, not by hierarchy. This may seem tedious, but you'll soon learn that everything about developing in Unity for mobile platforms is tedious.
thanks for the info on the performance of CCs. Its good to know, if there should be any additional slow downs in the game.
Answer by Wekthor · Jan 25, 2012 at 02:24 AM
So the solution was quite simple. There was probably some overload on collisions when the GOs were spawning in between them, so i just turned off the collisions in collision matrix for everything except the one GO it should collide with.