There's two errors. One of which is causing the compiler, and the other of which is just causing broken behavior. You have to assign the output of `Mathf.Clamp()` to something. `inAirVelocity` is passed by value so the function does not change the original value.
Then there is the compiler error. The error says that the arguments (everything inside the parentheses) don't match up with the existing definitions of clamp. When you call a function, Unity looks through all known definitions to see if the objects you passed as parameters line up with any of the definitions. Since they didn't, the compiler threw an error. In your case, you tried to pass a `Vector3`, an `int` and a `float`.
Here is the definition that you want.
static float Clamp(float value, float min, float max);
So here's what you actually want to do.
inAirVelocity = inAirVelocity.normalized * Mathf.Clamp ( inAirVelocity.magnitude , 0 , walkSpeed);
// or * Mathf.Min( inAirVelocity.magnitude , walkSpeed) since magnitude > 0
↧