Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Physics difference between EDITOR and BUILD

Discussion in 'Editor & General Support' started by Rackover, Apr 25, 2020.

  1. Rackover

    Rackover

    Joined:
    Apr 25, 2020
    Posts:
    9
    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?
     
  2. Rackover

    Rackover

    Joined:
    Apr 25, 2020
    Posts:
    9
    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?