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 SweepTest ColliderCast

Discussion in 'Physics' started by unity_44234FBC39E5661FBF5B, Dec 3, 2021.

  1. unity_44234FBC39E5661FBF5B

    unity_44234FBC39E5661FBF5B

    Joined:
    May 11, 2021
    Posts:
    29
    How would I implement a mesh collider to a wheel collider? The documentation of SweepTest doesn't state how to cast colliders.
     
  2. tjmaul

    tjmaul

    Joined:
    Aug 29, 2018
    Posts:
    464
    For SweepTest you need a dedicated rigidbody with some colliders attached. You can't directly pass colliders into the SweepTest function.

    From the documentation
    "Note that this function only works when a primitive collider type (sphere, cube or capsule) or a convex mesh is attached to the rigidbody object - concave mesh colliders will not work, although they can be detected in the Scene by the sweep."

    I'm not sure about your question, though.
     
  3. unity_44234FBC39E5661FBF5B

    unity_44234FBC39E5661FBF5B

    Joined:
    May 11, 2021
    Posts:
    29
    So the rigidbody and collider can't be in the same object?
     
  4. tjmaul

    tjmaul

    Joined:
    Aug 29, 2018
    Posts:
    464
    I don’t understand your question. The colliders and rigidbody can be in the same object, but don’t have to be. All colliders that are on the same gameobject as the rigidbody or their children and grandchildren (all the way down the hierarchy) make up the collision shape of the rigidbody. Now you can use this rigidbody and do a sweep test.

    Note, that this is totally separate from the actual vehicle that you’ll probably also have.

    have you tried to create a test scene and use the sweeptest? It’ll become clearer as soon as you do that
     
  5. unity_44234FBC39E5661FBF5B

    unity_44234FBC39E5661FBF5B

    Joined:
    May 11, 2021
    Posts:
    29
    I mean like if it is possible to use sweeptest on a wheel collider since I saw TheMrFeliX do it.