I am making a driving game without wheel colliders and I want the car to have more drag when one is driving but than when the car is in mid air it falls more slowly. I want to make the car have more drag horizontally than forward and backward because wheels only spin in one direction but I cant figure out any way to adjust RigidBody drag on only one axis. i have tried adjusting the cars physics material but that did not work. does anyone have any suggestions?
Thanks!
This doesn’t seem like it should be too hard to do overall; you just have to do it yourself.
Ensure that your vehicle has NO physics drag. Then, in your vehicle script, just include the way you want drag to be applied instead:
// Example of transferring Rigidbody.drag to a custom variation
Rigidbody rb;
float vehicleDrag;
void Start()
{
rb = GetComponent<Rigidbody>();
vehicleDrag = rb.drag;
rb.drag = 0f;
}
void FixedUpdate()
{
// Example based on PhysX's kinda-lousy implementation
// for consistent behavior
rigidbodyDrag = Mathf.Clamp01(1.0f - (vehicleDrag * Time.fixedDeltaTime));
rb.velocity -= rb.velocity * vehicleDrag * (transform.up + transform.right) * 0.5f;
}
In this example, the drag is scaled by the tangential (up/right) vectors of the vehicle to avoid dampening velocity along the remaining forward vector.
Thanks!
implementing my own drag system is a good idea.
while i do not think i will use your exact code it is a good start.
sorry for the late response.
have a good day!