Physics difference between EDITOR and BUILD

Hello,
I'm making a racing game and all my physics-related code is located inside a FixedUpdate() loop.

However, I still experience massive difference in the strength of the AddForces and velocities in my Editor and in the Build.

The game uses kinematic rigidbodies and simulate a gravity by AddForce()ing the vehicles to the ground, and the vehicles shoot raycasts on the ground to AddForceAtPosition() in the opposite direction and create a suspension effect.

When the two are correctly balanced, it creates a good "bouncy" effect and the car is at a reasonable distance from the ground. In the editor. Not in the build.

As you can see, in the build, the tires are below the ground and the collider of the car is actually just sliding on the track, while in the editor, the tires and the car are correctly above the ground because the car is pushed upwards the right amount.

The two are compiled from exactly the same code.
This code : https://github.com/Rackover/TrackMaster/blob/master/Assets/Script/Vehicle.cs#L115

How do I make it so that the build runs the same way than the editor does?

Update: The problem comes from the fact that Mesh colliders are working in the EDITOR, but not in the BUILD.
In the build, mesh colliders provide no collisions.

Why that?

One solution I hear going around is to handle all the physics under the void FixedUpdate() instead of the regular Update().

If that doesn't work another solution is: you know when you multiply values by Time.deltaTime? Replace deltaTime with fixedDeltaTime and that might help.

Hello, thank you very much, but I released my game four years ago :)
appreciate the answer still

2 Likes