1
\$\begingroup\$

I'm developing a vehicle simulator game for mobile platforms. This vehicle has some hydraulic arms. I use hinge joints and configurable joints. There can be collisions to walls etc.

When I set a low Fixed Timestep (more fixed updates, less performance) like 0.001 it runs smoothly on editor and it handles the collisions well. But on the target mobile device, the performance drops to 2-3 FPS! So 0.001 (1000 fixed updates per second) is not an option.

When I change the Fixed Timestep to its default 0.02 value or 0.01, performance becomes acceptable on mobile. But when collisions occur, the vehicle is torn apart and everything flies away at a high velocity as if there was an explosion.

How can I achieve stable physics with 0.02 Fixed Timestep?

Note: I don't set the velocity or transform position. I move the vehicle by applying torque to the wheels.

Update 1 : The problem happens when the vehicle hits an obstacle that has a collider but doesn't have a rigidbody.

\$\endgroup\$
  • \$\begingroup\$ Is simplifying your vehicle an option? Depending on your needs, it might be possible to use a simpler physics model and animate the articulations with scripts rather than simulating all the joints. Also, it would help if you shared some details of your vehicle setup. Sometimes a few numerical changes can drastically affect the stability of joints. \$\endgroup\$ – DMGregory May 9 '18 at 12:10
  • \$\begingroup\$ Thanks for the reply. The vehicle is a wheel loader. I can't simplify it any more, it is already at the basic level. It has a front loader bucket that is connected to body via some pistons and arms. All are connected by hinge joints and one configurable joint (for piston movement) \$\endgroup\$ – Levent Alpsal May 11 '18 at 7:41
  • \$\begingroup\$ The problem happens when the vehicle hits an obstacle that has a collider but no rigidbody. \$\endgroup\$ – Levent Alpsal May 11 '18 at 7:42
  • \$\begingroup\$ The human body is an amazing array of hinges and sliding muscles & sinews. Nonetheless, when we put humans in games, we generally don't model each articulation as a physics joint. So I encourage you to consider that not everything that looks like a joint to the player needs to be a sinulated joint in the physics system. \$\endgroup\$ – DMGregory May 11 '18 at 12:10
1
\$\begingroup\$

I solved it, "Enable Preprocessing" option should be disabled in the joints as described below:

"Uncheck the Joint’s Enable Preprocessing property. Disabling preprocessing can help prevent Joints from separating or moving erratically if they are forced into situations where there is no possible way to satisfy the Joint constraints. This can occur if Rigidbody components connected by Joints are pulled apart by static collision geometry (for example, spawning a Ragdoll partially inside a wall)."

From Unity docs

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.