How can I Lerp a float value based on the rigidbody velocity?

I came up with this and it actually works pretty good it might even be exactly what I want but

I don’t know if its accurate.

I want undesteer to be .3 when going slow and .15 when at maximum speed

understeer = Mathf.Lerp(.3f, .15f, rb.velocity.magnitude / 100);

The basics of the maths is sound there. `Math.Lerp`

expects a value from 0 to 1, so getting a 0-to-1 value by division is the common way to go. That said you may want to use values you can assign in the inspector, rather than constants in code.

Thanks, I guess the real question how do I get velocity.magnitude to a value between 0-1?

You already worked that out, you divide its `.magnitude`

against another value. That’s the general way you work out a percentage.

1 Like