For basic usage, please refer to the official Chinese document WheelCollider .
Let's add the points and pits I used in my own development.
The sliding inertia of the car:
increaseWheelCollider.wheelDampingRate
Car grip adjustment:
Forward Friction-> Stiffness (longitudinal, wheel forward and backward)
Sideways Friction-> Stiffness (horizontal, drift)
The car goes uphill and slides down:
1. Forward (Z) to increase the uphill WheelCollider.forwardFriction.asymptoteValue
,
reverse (-Z) to increase the uphill WheelCollider.forwardFriction.extremumValue
2. Reduce the mass of the body and increase the mass of the wheels
3. ReadjustWheelCollider.forwardFriction.asymptoteSlip
Note that the wheel orientation of the component cannot be changed manually, its orientation is the same as the orientation of the parent object WheelCollider
with the component.Rigidbody
The problem of easy rollover
is the solution that I think of at present is to see the inspiration of the tumbler, and the rigid center of gravity of the body can be lowered to reduce the situation of easy rollover.
The code to modify the center of gravity is as follows:
using UnityEngine;
public class ChangeCenterOfMass : MonoBehaviour
{
public Transform center;
private Rigidbody r;
void Start()
{
r = GetComponent<Rigidbody>();
}
void Update()
{
r.centerOfMass = center.localPosition;
}
}
Create an empty object under the node of the car to set the center of gravity position, pay attention to the assignment localPosition
.
Self-made demo screenshots
Related blogs about WheelCollider