I have been researching, studying, and tweaking the values for hours without any change in effect. The wheels keep sliding sideways and are unable to grip the ground when they have torque.
My setup is unique, with a 3D planet and a large collider:
My vehicle follows the Unity tutorial on the subject. It’s just a simple test rectangle with a light weight Rigidbody (1.5). Changing the mass or size has not caused any significant difference.
My wheel collider settings have varied, but do not cause change. For instance:
Forward Friction
- Extremum Slip: 0.001
- Extremum Value: 1e+09
- Asymptote Slip: 0.002
- Asymptote Value: 1e+09
- Stiffness: 1
Sideways Friction
- Extremum Slip: 0.001
- Extremum Value: 1e+09
- Asymptote Slip: 0.002
- Asymptote Value: 1e+09
- Stiffness: 1
Where I set my values does not make a difference. Even halving the pull of gravity does not have a difference.
Is there a reason the wheel collider settings might be ignored?
I did a quick test with the following code.
This allows you to test two methods.
- Changing gravity settings based on the position of one car on a centre object.
- Discard gravity and add G force to as many cars based on their position on center object.
My goal was to tell if the Wheel Collider is somehow using Physics.gravity to do its math. In which case, you couldn’t have different gravities in different locations for more than one car.
I’ve put a 800Kg car on a Sphere of 1000 units diameter, and tested both techniques.
I couldn’t see much difference in the behaviour of the car.
I’ve tried with a Sphere of 100 units. Same thing.
So it seems it’s possible to have cars work with spherical gravity. The problem may be with the Wheel Collider settings.
Hope this helps.
using UnityEngine;
public class GravityCenter : MonoBehaviour
{
public enum GravityMode {PhysicsGravity, AddForce}
[SerializeField] Transform _center;
[SerializeField] float _G = -9.81f;
[SerializeField] GravityMode _mode;
Rigidbody _rigidbody;
void Awake ()
{
_rigidbody = GetComponent<Rigidbody>();
_rigidbody.useGravity = _mode == GravityMode.PhysicsGravity;
Physics.gravity = Vector3.up * _G;
}
void Update ()
{
if (_mode != GravityMode.PhysicsGravity)
return;
Physics.gravity = (_center.position - transform.position).normalized * - _G;
}
void FixedUpdate ()
{
if (_mode != GravityMode.AddForce)
return;
_rigidbody.AddForce((_center.position - transform.position).normalized * - _G, ForceMode.Acceleration);
}
}