- Home /
Physics update on certain objects.
Is it possible to make certain objects have special physics updates? For example, a player's car would update every 0.01 seconds, while the traffic cars would update at 0.05 seconds to avoid lag.
Answer by tanoshimi · Jul 11, 2015 at 11:19 AM
Depends what you mean by "Physics Updates". If you mean Unity's internal rigidbody movement, collision detection etc., then no, I don't believe so - you set a global Physics timestep that determines all physics updates.
If you simply mean the rate at which FixedUpdate() fires for each object, you could use InvokeRepeating or a coroutine to call a repeating function less frequently.
Unfortunately, what I was looking for was the custom physics update(to avoid lag). Thanks for the answer though!
Answer by zohaib817 · Jul 11, 2015 at 11:13 AM
yes, in each update function take a "float timer" and add Time.delta time to it. like this you can achieve your goal. void FixedUpdate(){ timer += Time.deltatime;
if(timer >= 0.01) { // do your stuff timer = 0 } }
Unfortunately, what I was looking for was the custom physics update(to avoid lag). Thanks for the answer though!
Your answer
![](https://koobas.hobune.stream/wayback/20220611230739im_/https://answers.unity.com/themes/thub/images/avi.jpg)