mathf inverselerp

Solutions on MaxInterview for mathf inverselerp by the best coders in the world

showing results for - "mathf inverselerp"
Benjamin
30 Jun 2020
1Calculates the linear parameter t that produces the interpolant value within the range [a, b].
2
3The a and b values define the start and end of the line. Value is a location between a and b. Subtract a from both a and b and value to make a', b' and value'. This makes a' to be zero and b' and value' to be reduced. Finally divide value' by b'. This gives the InverseLerp amount.
4
5using UnityEngine;
6using System.Collections;
7
8public class ExampleClass : MonoBehaviour
9{
10    public float walkSpeed = 5.0f;
11    public float runSpeed = 10.0f;
12    public float speed = 8.0f;
13
14    void Start()
15    {
16        float parameter = Mathf.InverseLerp(walkSpeed, runSpeed, speed);
17        Debug.Log("InverseLerp: 5, 10, 8 = " + parameter);
18    }
19}
queries leading to this page
mathf inverselerpmathf inverselerp