Search Unity

Odd Vehicle Collisions When Updating To 2018.3 [solved]

Discussion in 'Physics' started by JTPrime, Apr 12, 2019.

  1. JTPrime

    JTPrime

    Joined:
    Apr 12, 2019
    Posts:
    12
    Since the integration of the new PhysX update in Unity my vehicle "bounces" when traversing across two different (perfectly aligned) road/wall colliders, and also when driving along curved/inclined track pieces.

    I don't believe this is a WheelCollider problem as I have removed the car's collision layer from my road layer in the collision matrix, which seems to avoid the problem. This problem can even occur when the vehicle is 5-10 meters (units) away from the upcoming change in the new track section.

    For my vehicle collider, I've tried using a basic convex mesh for my vehicle (which worked fine in previous versions of Unity), a primitive Unity cube stretched into a rectangle. I've also tried different friction settings for physics materials, different mesh import settings for the track, Unity planes/quads for the track pieces, letting the vehicle coast without any script running on the vehicle, trial-and-error in the project's physics settings... I'm still getting the same result. Starting to think this is a bug.

    Any help is appreciated!

    The videos below demonstrate what happens when crossing the threshold between two track pieces.

     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Try using planes instead of boxes for your floor and walls. Looks like the car collider is so close to the ground that hits the vertical sides of the boxes (first video). Even when there's certain distance, the physics system computes the contacts a bit further than the collider faces.

    Also, I'd recommend you to review your car's collider so it leaves some room with the ground, even if it doesn't match the visual geometry entirely. Here are some hints on creating the car's collider:

    https://forum.unity.com/threads/creating-colliders-for-complex-meshes-in-an-efficient-way.658519/
     
    JTPrime likes this.
  3. JTPrime

    JTPrime

    Joined:
    Apr 12, 2019
    Posts:
    12
    Thanks for the reply!

    I discovered that it was a change in the collision detection mode causing the problem while investigating what you mentioned during runtime: swapping out my collider with one of yours from your package (which is great, by the way).

    Unity now automatically switches the collision detection to "Continuous Speculative" when you enable a rigidbody as kinematic, which I was initially doing during the scene setup before placing the car. While it switches the collision detection mode, it does not update the changes to the collision detection in the dropdown menu, so there's no indication that it has changed.

    In order to get it to work during runtime, I had to change the collision detection to something other than its original setting and then back to its original setting, then deactivate/reactivate the gameObject with the attached rigidbody. In the end I removed the "isKinematic" code altogether and it now works like a charm.

    I'm going to look into all the specifics of how to repo it later today and possibly report it as a bug.

    Thanks again!
     
    Last edited: Apr 13, 2019
  4. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Yes, that's totally a bug. I often toggle the isKinematic flag enabled and disabled in runtime, as the Replay mode works by moving kinematic bodies. However, I haven't noticed anything strange after that, maybe because my setups are more forgiving in general.

    The bug report should help Unity guys to fix it asap.
     
  5. RamSteelwood

    RamSteelwood

    Joined:
    Mar 6, 2013
    Posts:
    19
    Thanks JTPrime. I've been having the same issue since upgrading to 2018.3 (and later) and was really struggling to identify the cause. The toggling of 'isKinematic' was it.

    My solution for now was to add some code to override the collision detection mode whenever we change the isKinematic setting.
    Weirdly, I found that just doing this after each time we set the isKinematic to false didn't always 'take'...I had to also override the mode after setting the isKinematic to true as well, even though that would always be followed by a false a few seconds later for the player to resume. Just for context, in our game if you 'reset to track' the cars are picked up and flown back to the road, during this they're set to iskinematic=true so they can't be moved manually along a path without momentum etc., then set back to false for the player to start driving again.