Global/LerpAngle

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Initial Creation)
m (Also menu state)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{Func
 
{{Func
|Name=LerpAngle
 
|Parent=Global
 
 
|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
 +
|Parent=Global
 
}}
 
}}
 
{{Arg
 
{{Arg
Line 33: Line 33:
 
timer.Create("Turn", 0.1, 10, function()
 
timer.Create("Turn", 0.1, 10, function()
 
     ratio = ratio + 0.1
 
     ratio = ratio + 0.1
     entity:SetAngle(Lerp(ratio, startAngle, endAngle))
+
     entity:SetAngles(Lerp(ratio, startAngle, endAngle))
 
end)
 
end)
 
}}
 
}}

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