1
votes
void FixedUpdate()
{
    ///rotate character model if stick is tilted right or left, but only if character is moving in that direction.
    if (IsInLocomotion () && ((direction >= 0 && horizontal >= 0) || (direction < 0 && horizontal < 0))) 
    {
        Vector3 rotationAmount = Vector3.Lerp (Vector3.zero, new Vector3 (0f, rotationDegreePerSecond* (horizontal < 0f ? -1f : 1f), 0f), Mathf.Abs);
        Quaternion deltaRotation = Quaternion.Euler (rotationAmount * Time.deltaTime);
        this.transform.rotation = (this.transform.rotation * deltaRotation);
    }

}

this one specific part of my code is giving me an error. If anyone would happen to know what exactly is wrong with it it i would be very grateful.

i keep getting the error

Assets/CharacterControllerLogics.cs(100,58): error CS1502: The best overloaded method match for `UnityEngine.Vector3.Lerp(UnityEngine.Vector3, UnityEngine.Vector3, float)' has some invalid arguments

and

Assets/CharacterControllerLogics.cs(100,58): error CS1503: Argument #3' cannot convertmethod group' expression to type `float'

1

1 Answers

3
votes

You're passing Mathf.Abs (a method) to a method that's expecting a float as its third parameter. Perhaps you are supposed to be supplying a value to Mathf.Abs (the result of which would be of type float)? e.g.:

Vector3.Lerp (Vector3.zero, new Vector3 (0f, rotationDegreePerSecond * 
    (horizontal < 0f ? -1f : 1f), 0f), Mathf.Abs(42.0));
                                                ^^^^^^