Search Unity

Issues with colliders and rigidbodies using Realistic Car Controller

Discussion in 'Physics' started by rapidrunner, May 20, 2018.

  1. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    I am using a bus model, and I want to apply the Realistic Car Controller V3 on it.

    So far, the issue is that if you follow the instructions, you need to apply a convex collider to the mesh you use, but in my case, this means that my first person controller cannot get inside the bus.
    If the convex is on, then you can't get inside the bus, but the car controller works. If I turn convex off, the bus just roll around on its own.

    Is there a way to have a convex collider that does not cover also some areas? Seems that the collider implicitly close all the openings (doors and windows), even if there is no geometry there.

    Also Unity is complaining about this:
    Code (CSharp):
    1. Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported in Unity 5.
    2. If you want to use a non-convex mesh either make the Rigidbody kinematic or remove the Rigidbody component.
    Which is something that I never noticed before.
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Any collider with a Rigidbody requires a convex collider. This requirement started with Unity 5 / PhysX 3 (previously, Unity 4- / PhysX 2 had different requirements).

    In your case you should have two different collider sets in different layers: one set for the vehicle's collisions (exterior, colliding with other vehicles and environment) and other set for the vehicle's interior and exterior (excepting doors when they're open). Character colliders would collide with this latest set. Note that you will still need these colliders to be convex. You should compose the interior using convex colliders (i.e. box colliders for the bus "walls" and seats, capsule colliders for the bars, etc).

    Then you may simply use the Layer Collision Matrix (Edit > Preferences > Physics) to ensure that the character collider collides only with the "interior" colliders, not the vehicle's collider.
     
    Last edited: May 24, 2018
  3. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    Thanks for the tips; I never spent much time on collider in the past, so they were working and I didn't even dig much into it.
    How they say, you notice things when you loose them :) I need to divide the interior mesh, so it is possible to have convex without obstruct the passage, otherwise the capsule collider around the first person controller.

    I just wish that Unity would allow to move and resize more easily the various colliders; takes me forever to make complex meshes covered with colliders, because I have to use the values instead than just a gizmo

    BTW as side note, I do have your vehicle package, and I totally forgot to have it. I need to import it and give it a spin.
     
  4. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    I think it's better to create the interior in the 3D modelling tool. Just ensure to use convex shapes. Then all you have to do is marking them as "convex" and moving them to the proper layer in Unity.

    Thanks!