Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Simple Tire setup is not working.

Discussion in 'Physics' started by DanVioletSagmiller, Aug 22, 2019.

  1. DanVioletSagmiller

    DanVioletSagmiller

    Joined:
    Aug 26, 2010
    Posts:
    123
    I'm creating a very simple custom wheel and trying to get it to work.I recorded a 3 min video going over the details you can see, but here they are in text.

    - The truck body has a rigid body. On that are child wheel objects.
    - The wheel objects have no phyics, but just ask a child rotor object (also empty of physics) to transform.rotate.
    - The rotor has several child cubes, at intervals around it. So when the rotor spins, it causes the cubes to rotate around the rotor.
    - When running over a physical model with a jagged surface, the cubes cause it to pull itself across.
    - When it sits on a flat surface, it goes nowhere.
    - Each collider (wheel and ground) have physical materials attached, with friction. But still the same results.

    I'm wondering if there is an easy way to set this up, or if I need to work out the math to make the tire physics work. Any advice would be appreciated.

    - Thanks.



     
  2. vagelis199

    vagelis199

    Joined:
    Jul 27, 2012
    Posts:
    35
    Well physics dont work quite well on unity, I suggest you to use unity's wheel coliders instead and just apply motor torque to the wheel collider through script OR just apply some rigidbody velocity to your vehicle based on the wheel rotation speed or better vice versa.
     
  3. radialxawn

    radialxawn

    Joined:
    May 13, 2019
    Posts:
    29
    Well, you cant make a car like that, a property way to move a rigidbody is adding force on it, moving collider in rigidbody just change the shape of collision not the force, your left car can move because of the triangle obstacles, look at it and you will see that the car just slide down the triangle and move forward.
    If you want to make that type of car you should use hinge joint to connect rigidbody wheels to a rigidbody car body and then add torque to the wheel.
     
  4. Marcos-Schultz

    Marcos-Schultz

    Joined:
    Feb 24, 2014
    Posts:
    289
  5. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,542
    That's the problem. Transform.rotate just "teleports" the objects, but there are no physics interactions. Running on the jagged surface seems to work because the colliders overlap slightly while rotating, and that triggers the physics to separate them. But the model would experience weird effects if the rotation is fast enough.

    In your particular setup the "wheels" should be rigidbodies attached to the car's rigidbody with joints. Then use either the joint's motor properties or AddForce/AddTorque for them to interact physically with the environment.