Physics gets less precise with lag

Hi there... I'm new to Unity and game programming, and I'm coming up against a problem that I'm not sure how to approach.

I'm working on a project that involves letting the player spawn a large number of objects with mesh colliders that interact constantly with each other and the map. Additionally, kinematic objects around the map push against these objects and move them around.

All is mostly well, but I've noticed that when a lot of objects are in the scene, or when system or device performance is otherwise slow, the physics engine seems to take shortcuts: objects get jammed into walls and crevices, and the kinematic map elements will fail to collide with the objects.

It's absolutely vital to this game that the physics behaves consistently regardless of performance, but it is acceptable if things slow down if they need to.

How can I tweak the physics settings so that the engine favors accuracy (or at least consistency) over frame rate?

Thanks!

1 Answer

1

Reducing fixed timestep might help. See http://unity3d.com/support/documentation/Components/class-TimeManager.html.

I think Maximum Allowed Timestep is the actual lever I want, but this is exactly the area I need to be tweaking. Thanks so much for the quick response.

As it happens, I can't seem to improve on my current values. If I lower my timestep, my objects never seem to come to rest, and quiver endlessly atop each other. Raising the threshold seems like it might be helping a bit, but I can't tell. So, I am stuck again. How can I go about forcing the physics engine to behave consistently?

Still struggling with this one. It seems the levers I can pull are: * Spatial scale * Time scale * Gravity * Object Mass Of course, messing with any of these requires all of the others to be tweaked, and even in the best case, I'm STILL left with the problem that the physics engine takes shortcuts if lag gets bad. I'm thinking of trying to implement a lag-watching system that detects when frame rate has dropped and begins reducing quality level until we're out of frame rate panic mode. Has anyone looked at this?

Any sort of tweaking with timesteps throws the game behavior way outside of normal/acceptable parameters. It's not really a feasible option unless I can find a way to make it behave.