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. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Question Car Falling through Ground Plane

Discussion in 'Physics' started by UnityFledgling, Apr 16, 2023.

  1. UnityFledgling

    UnityFledgling

    Joined:
    Jan 30, 2022
    Posts:
    20
    This is frustrating and I can't figure it out.

    When I hit the Play button, a car I have set up keeps falling through the ground and the tires fly off.

    I have set up the car with a Rigidbody component (Mass = 1200) and a Box Collider on it.

    I have applied Wheel Collider components to the game objects named, WheelColliderLeftFront, etc. I sized the colliders and placed them within the wheel meshes.

    The ground plane has a box collider and I set the Constraints to be active for Position X, Y, and Z.

    What have I done wrong?
     
    Last edited: Apr 18, 2023
  2. t-ley

    t-ley

    Joined:
    Mar 6, 2017
    Posts:
    68
    Which version cause the last two versions have different collider and rigid body layers
    A lot of the times Unity sets a tag to blank depending on the asset, see if it’s on default
     
    UnityFledgling likes this.
  3. UnityFledgling

    UnityFledgling

    Joined:
    Jan 30, 2022
    Posts:
    20
    The car now drops to the surface of the race track while the wheels drop through the race track and continue to fall downward.
     
  4. t-ley

    t-ley

    Joined:
    Mar 6, 2017
    Posts:
    68
    Could check in edit/project settings/physics/simulation mode and see if it’s on fixed update is goes on script by default
    Or play with the physics table at the bottom to see if the wheel collier layer and the ground layer are checked
    Do the colliders have a script on them?
     
    Last edited: Apr 18, 2023
    UnityFledgling likes this.
  5. UnityFledgling

    UnityFledgling

    Joined:
    Jan 30, 2022
    Posts:
    20
    The Car itself has the script. It's one I typed while watching Imphenzia on YouTube:

    The matrix at the bottom of the Physics preferences are all checked.


    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class Car : MonoBehaviour
    {
    public WheelCollider wheelColliderLeftFront;
    public WheelCollider wheelColliderRightFront;
    public WheelCollider wheelColliderLeftBack;
    public WheelCollider wheelColliderRightBack;

    public Transform wheelLeftFront;
    public Transform wheelRightFront;
    public Transform wheelLeftBack;
    public Transform wheelRightBack;

    public float motorTorque = 100f;
    public float maxSteer = 20f;


    void FixedUpdate()
    {
    wheelColliderLeftBack.motorTorque = Input.GetAxis("Vertical") * motorTorque;
    wheelColliderRightBack.motorTorque = Input.GetAxis("Vertical") * motorTorque;
    }

    }
     
  6. UnityFledgling

    UnityFledgling

    Joined:
    Jan 30, 2022
    Posts:
    20
    Okay, I see what I did wrong. I didn't add the following to the bottom of the script:


    void Update()
    {
    var pos = Vector3.zero;
    var rot = Quaternion.identity;

    wheelColliderLeftFront.GetWorldPose(out pos, out rot);
    wheelLeftFront.position = pos;
    wheelLeftFront.rotation = rot;

    wheelColliderRightFront.GetWorldPose(out pos, out rot);
    wheelRightFront.position = pos;
    wheelRightFront.rotation = rot;

    wheelColliderLeftBack.GetWorldPose(out pos, out rot);
    wheelLeftBack.position = pos;
    wheelLeftBack.rotation = rot;

    wheelColliderRightBack.GetWorldPose(out pos, out rot);
    wheelRightBack.position = pos;
    wheelRightBack.rotation = rot;
    }

    This attaches the colliders and wheels together, and to the car.
     
  7. t-ley

    t-ley

    Joined:
    Mar 6, 2017
    Posts:
    68
    cool
     
  8. UnityFledgling

    UnityFledgling

    Joined:
    Jan 30, 2022
    Posts:
    20
    Again, the wheels drop off the car and fall through the surface of the plane.

    I've tripled-checked the settings.

    I am dying here!
     
  9. UnityFledgling

    UnityFledgling

    Joined:
    Jan 30, 2022
    Posts:
    20
    The Wheel meshes need to be set to IsKinematic in the Rigidbody components.
     
  10. t-ley

    t-ley

    Joined:
    Mar 6, 2017
    Posts:
    68
    Maybe mess with the
    Interpolate on the rigibody
    Like ragdoll flop all over if the rigibodies aren’t set to Continuous Speculative and set to kinematic
     
  11. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,218
    Interpolation/Extrapolation is a function to update the Transform per-frame; it causes absolutely no behavioural difference to the physics simulation.
     
    UnityFledgling likes this.
  12. t-ley

    t-ley

    Joined:
    Mar 6, 2017
    Posts:
    68
    Cool
    Good luck with ur project
     
  13. t-ley

    t-ley

    Joined:
    Mar 6, 2017
    Posts:
    68
    Since ur here answering
    What does Calling BeginWrite before EndWrite mean it’s giving nothing to go on?
    And why does Unity only answer certain problems?
     
    Last edited: Apr 21, 2023
  14. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,218
    I have no idea what you're referring to.

    Who's "Unity" specifically? I personally try to answer every question in my area I find.
     
  15. t-ley

    t-ley

    Joined:
    Mar 6, 2017
    Posts:
    68
    An error on the console Calling EndWrite before BeginWrite
    I asked for some with Asset Refresh Plugin
    Error before and nothing any idea what it is referring to?
    If I knew I’d get rid or try to fix something but what?
     
  16. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,218
    So hijack this thread with your question? I am a 2D physics engineer, I have no idea what this is referring to.

    I've searched and found your other thread you posted only 25 mins ago. Wait until someone answers please.
     
  17. t-ley

    t-ley

    Joined:
    Mar 6, 2017
    Posts:
    68
    I’m not trying to take over this thread
    Wow
    I just figured u knew that’s why I asked
    Cause ur Unity
     
  18. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,218
    Asking a completely different question on someone elses thread is a hijack, by definition. Please be patient and wait for a response to your other thread.

    Thanks.
     
  19. t-ley

    t-ley

    Joined:
    Mar 6, 2017
    Posts:
    68
    My fault but the guy asked a week ago and u didn’t answer him u answered my post
    He was asking for help first, thanks for letting me know about other questions on other posts I’m gonna unwatch this thread sorry