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)

Page Links


Special Pages


Wikis

?

Render Time: 56ms

DB GetPage 22
Generate Html 9
SaveChanges (1) 10
Render Body 0
Render Sidebar 12