How to set rigidbody drag for each x,y,z?

For an example, i wanna set the x drag 5 while the y drag is 10. How can i do this?

``````using UnityEngine;

public class CustomDrag : MonoBehaviour
{
public float xDrag = 5f;
public float yDrag = 10f;
public float zDrag = 0f;

private Rigidbody rb;

void Start()
{
rb = GetComponent<Rigidbody>();
}

void FixedUpdate()
{
// Custom drag for linear movement
Vector3 currentVelocity = rb.velocity;
currentVelocity.x *= Mathf.Pow(1f - xDrag * Time.fixedDeltaTime, Time.fixedDeltaTime);
currentVelocity.y *= Mathf.Pow(1f - yDrag * Time.fixedDeltaTime, Time.fixedDeltaTime);
currentVelocity.z *= Mathf.Pow(1f - zDrag * Time.fixedDeltaTime, Time.fixedDeltaTime);
rb.velocity = currentVelocity;

// Angular drag (adjust as needed)
Vector3 currentAngularVelocity = rb.angularVelocity;
currentAngularVelocity.x *= Mathf.Pow(1f - xDrag * Time.fixedDeltaTime, Time.fixedDeltaTime);
currentAngularVelocity.y *= Mathf.Pow(1f - yDrag * Time.fixedDeltaTime, Time.fixedDeltaTime);
currentAngularVelocity.z *= Mathf.Pow(1f - zDrag * Time.fixedDeltaTime, Time.fixedDeltaTime);
rb.angularVelocity = currentAngularVelocity;
}
}
``````

In this example, I’m applying custom drag to the linear movement by modifying the `rb.velocity` directly for each axis. I hope this will help you.