Global/LerpAngle

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(The example was talking about any entity, not a player.)
m (Also menu state)
 
Line 1: Line 1:
 
{{Func
 
{{Func
 
|Description=Returns point between first and second angle using given fraction and linear interpolation
 
|Description=Returns point between first and second angle using given fraction and linear interpolation
|Realm=Shared
+
|Realm=Shared and Menu
 
|IsClass=No
 
|IsClass=No
 
|Name=LerpAngle
 
|Name=LerpAngle

Latest revision as of 16:42, 10 July 2016

 LerpAngle( )

Contents

Description

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

Arguments

number ratio

Ratio of progress through values

Arguments

Angle angleStart

Angle to begin from

Arguments

Angle angleEnd

Angle to end at

Returns

Angle

angle

Examples

Example

Turns an entity 180 degrees uses lerp 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(Lerp(ratio, startAngle, endAngle))
end)


Personal tools
Navigation