Wheel Collider Bouncing insanely.,Wheel collider bouncing insanely

I took a cube, applied rigid body to it.
I made an empty object added wheel collider to it, and made it a child of the cube.
Now when I play the scene, the Cube bounces off the surface to infinity.
Why? and How do I fix it??

Thanks and regards in advance.

I don’t know :slight_smile: Seems to be keeping the root as a empty object with the rigid body on that.
Also have the wheel colliders in a child empty object that is a child of the root.
That seems to have much better effect and keeps things clearer and more organisable, but read the tutorial.

I was the same and just ran through this little tutorial.

I haven’t a clue why placing in empty objects as the above works and what I have done before hasn’t but try the above

I am a noob also so forgive my hacking but with multi-axle and multi steer things didn’t work, so I added a really rough approximation routine.
Then wondered why does this thing roll so easy and added another rough approximation of an anti roll bar.
Still confused of how much contact area a wheel actually gets as tyres compress and on softer surfaces wheels dig in and gain traction.
But hey my script is here use the above tutorial by creating objects just as it does and give that a try then it becomes very easy just to attach whatever you need.
Apply the script to the root empty object and away you go.

 using UnityEngine;
using System.Collections;
using System.Collections.Generic;
 
[System.Serializable]
public class AxleInfo
{
    public WheelCollider leftWheel;
    public WheelCollider rightWheel;
    public bool motor;
    public bool steering;
 
}
 
public class SimpleCarController : MonoBehaviour
{
    public List<AxleInfo> axleInfos;
    public float maxMotorTorque = 3000.0f;
    public float maxSteeringAngle = 25.0f;
    public float antiRoll = 5000.0f;
 
    // finds the corresponding visual wheel
    // correctly applies the transform
    public void ApplyLocalPositionToVisuals(WheelCollider collider)
    {
        if (collider.transform.childCount == 0)
        {
            return;
        }
 
        Transform visualWheel = collider.transform.GetChild(0);
 
        Vector3 position;
        Quaternion rotation;
        collider.GetWorldPose(out position, out rotation);
 
        visualWheel.transform.position = position;
        visualWheel.transform.rotation = rotation;
    }
 
    public void FixedUpdate()
    {
        float motor = maxMotorTorque * Input.GetAxis("Vertical");
        float steering = maxSteeringAngle * Input.GetAxis("Horizontal");
     
        for (int i = 0; i < axleInfos.Count; i++)
            {
 
            WheelHit hit;
            float travelL = 1.0f;
            float travelR = 1.0f;
 
            bool groundedL = axleInfos*.leftWheel.GetGroundHit(out hit);*

if (groundedL)
travelL = (-axleInfos.leftWheel.transform.InverseTransformPoint(hit.point).y - axleInfos_.leftWheel.radius) / axleInfos*.leftWheel.suspensionDistance;_
_bool groundedR = axleInfos.rightWheel.GetGroundHit(out hit);
if (groundedR)
travelR = (-axleInfos.rightWheel.transform.InverseTransformPoint(hit.point).y - axleInfos.rightWheel.radius) / axleInfos.rightWheel.suspensionDistance;*_

float antiRollForce = (travelL - travelR) * antiRoll;

if (groundedL)
GetComponent().AddForceAtPosition(axleInfos_.leftWheel.transform.up * -antiRollForce,
axleInfos*.leftWheel.transform.position);*
if (groundedR)
GetComponent().AddForceAtPosition(axleInfos.rightWheel.transform.up * antiRollForce,_

axleInfos*.rightWheel.transform.position);*

if (axleInfos*.steering)*

{
if (i + 1 <= axleInfos.Count / 2)
{
axleInfos*.leftWheel.steerAngle = steering / (1 + i);*
axleInfos*.rightWheel.steerAngle = steering / (1 + i);*
}
else
{
axleInfos*.leftWheel.steerAngle = -steering / (1 + axleInfos.Count - i);*
axleInfos*.rightWheel.steerAngle = -steering / (1 + axleInfos.Count - i);*
}
}
if (axleInfos*.motor)*
{
axleInfos*.leftWheel.motorTorque = motor / axleInfos.Count / 2;*
axleInfos*.rightWheel.motorTorque = motor / axleInfos.Count / 2;*
}

ApplyLocalPositionToVisuals(axleInfos*.leftWheel);*
ApplyLocalPositionToVisuals(axleInfos*.rightWheel);*
}
}
}
If anyone fancies cleaning up my horrid code please do.
Really each axles distance from the front if a rear axle and from rear if rear to the centre of the vehicle should give the tangent of what the same turning circle should be for the current axle, via its distance to centre of turn.
I thought about it and said hey way too much maths and just divided by axle number.
Being zero based it was +1
1st axle / 1 so full steer value
2nd /2 50%
3rd /3 33 %
and so on seems to work with 8 wheels maybe someone will do the proper maths.
With above 4 wheels (2 axles) it checks if we are over half the number of axles and then those wheels steer in the opposite action to the front so you actually turn rather than skit sideways.
You can select each axle if its powered or steers.