- Home /
Managing and optmizing too many colliding objects
hi I have a big city , with 100 cars. each car has 2-3 box collider and trigger. Car meshes are low poly. performance is low. Is there any optimization available?
Firstly I'm guessing all of the cars that are moving have rigidbodies? Setting your physics collision layers may help (ignoring unused collisions). You could also try disabling physics for things outside the current view and/or reducing the number of colliders for distant objects.
What collision routines are you using (OnXXXXStay etc)
Thanks. all of the cars , according to what Unity says about moving objects , have rigid body attached , and I use layer based collision detection. I use OnTriggerEnter only. I think physics should not be disabled for objects out of camera frustum , or far objects , because cars may go through each other , and when I approach them , it may cause problems.
First of all, is this lag also when you diseable the physics?
If not, then you search at the wrong point.
If yes, then you should use only one collider (full bounding box) the other colliders should be set to TriggerOnly. Then you should check how many colliders the other objects have (houses etc).
In GTA for example, cars which are far away gets they're collider diseabled, ins$$anonymous$$d, they just drive normal on the street (no collision at all).
Perhaps you should try that. ;)
With no physics , FPS is much higher. I should check my colliders again. thanks for now.
It's very common to "physicalise" objects within a certain radius of the player and allow standard AI logic to deal with situations beyond that.
Answer by belvita · Dec 01, 2013 at 08:40 AM
Do not use mesh colliders if it is a serious mesh u got on ur cars the calculation takes time for unity instead delete mesh collider and add a box collider for ur cars and other objects
You are right, those mesh colliders are expensive, but...
As alirakiyan said:
"each car has 2-3 box collider".
There are no mesh colliders.
we need to see your code ,this problem may exist because of the way u design ur game.show some code please
Your answer
Follow this Question
Related Questions
Meshcollider count VS Meshcollider vertex count? 0 Answers
[C#] Game runs oddly slow 2 Answers
Rigidbody Overhead 1 Answer
does interpolation full up some kind of cache over time 1 Answer
2D physics performance on iPhone 0 Answers