- Home /
Physic processing takes a lot of time for one rigidbody
Hi,
I'm trying to figure out if there is a way to reduce the cost of the physic processing.
Here is my setup :
I have only one rigidbody on one gameobject.
I'm using physic for a few triggers in my game, but to test the physic processing cost, i deactivated all the triggers colliders from my game, so i only have one item, with one collider and rigidbody.
This item is not even moving most of the time.
I ticked the "IsKinematic" checkbox because i move this object in script. I also freeze all its positions and rotations.
The result i got, on my computer : 0.16ms every 2 frames for the physic computation of ONE item (that is not even moving) on my computer. On mobile it takes 1ms.
Is it normal ? Am i doing something wrong ?
Here are some screenshots of the results:
Thanks.
Answer by Vega4Life · Dec 06, 2018 at 06:57 PM
This is the cost of using the Physics process. You shouldn't think if you duped your object and had two, the cost doubles. It won't. In fact, with what you have, if you duped 1000 of those objects, it should still be around your 0.16 ms. (Also, I would pay more attention to Calls, then necessarily Time ms. A lot of calls to the physics process is usually a sign of badness.)
I personally don't think 1ms is that slow, considering that Update() in your scripts is way more costly. And is usually why we have workarounds for many, many duped objects using Update(). Instead, you create a UpdateMe() function, then a manager of those scripts, calls into UpdateMe() through its update. (Although, this may not be much of a thing anymore - it's something we did in our games to squeeze out some perf).