Skip to content

Math.Lerp

Name Mandatory Description Default Type
⬅️ Input The factor to interpolate between the start and end values. Float
Output ➡️ The interpolated value between the start and end values based on the factor provided as input. IntInt2Int3Int4Int8Int16FloatFloat2Float3Float4Color[Any]
First No The start value none IntVar(Int)Int2Var(Int2)Int3Var(Int3)Int4Var(Int4)Int8Var(Int8)Int16Var(Int16)FloatVar(Float)Float2Var(Float2)Float3Var(Float3)Float4Var(Float4)ColorVar(Color)
Second No The end value none IntVar(Int)Int2Var(Int2)Int3Var(Int3)Int4Var(Int4)Int8Var(Int8)Int16Var(Int16)FloatVar(Float)Float2Var(Float2)Float3Var(Float3)Float4Var(Float4)ColorVar(Color)

Linearly interpolate between the start value specified in the First parameter and the end value specified in the Second parameter based on the factor provided as input.

Details

The value in the First parameter and the Second parameter must be of the same type.

If the integers are provided in the First and Second parameters, the output of the shard will be an integer rounded down to the nearest integer.

If vectors are provided in the First and Second parameters, The first element in the First vector will be linearly interpolated to the first element in the Second vector, the second element in the First vector will be linearly interpolated to the second element in the Second vector, and so on.

Do note that the output of the shard is not automatically written to the value in the First parameter. Consider the following example:

@wire(lerp {
  Once({
    0 >= x
  })

  0.1
  Math.Lerp(First: x Second: 100)
  Log("Result")
} Looped: true)
The output will always be 10 regardless of how many times the Math.Lerp shard is called. For the output value to progress, you must write the output back to x. Like so:
@wire(lerp {
  Once({
    0 >= x
  })

  0.1
  Math.Lerp(First: x Second: 100)
  > x
  Log("Result")
} Looped: true)
Now the first time Math.Ler is called the output will be 10, then 20 and so on.