Garry's Mod Wiki

LerpAngle

  Angle LerpAngle( number ratio, Angle angleStart, Angle angleEnd )

Description

Returns point between first and second angle using given fraction and linear interpolation

This function is not meant to be used with constant value in the first argument, if you're dealing with animation! Use a value that changes over time

Arguments

1 number ratio
Ratio of progress through values
2 Angle angleStart
Angle to begin from
3 Angle angleEnd
Angle to end at

Returns

1 Angle
angle

Example

Turns an entity 180 degrees linearly over ten seconds

local startAngle = Angle(0, 0, 0) local endAngle = Angle(0, 180, 0) local ratio = 0 timer.Create("Turn", 0.1, 10, function() ratio = ratio + 0.1 entity:SetAngles(LerpAngle(ratio, startAngle, endAngle)) end)