Global/LerpAngle

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Func |Name=LerpAngle |Parent=Global |Description= |Realm=Shared |IsClass=No }} ")
 
m (Also menu state)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{Func
 
{{Func
 +
|Description=Returns point between first and second angle using given fraction and linear interpolation
 +
|Realm=Shared and Menu
 +
|IsClass=No
 
|Name=LerpAngle
 
|Name=LerpAngle
 
|Parent=Global
 
|Parent=Global
|Description=
+
}}
|Realm=Shared
+
{{Arg
|IsClass=No
+
|type=number
 +
|name=ratio
 +
|desc=Ratio of progress through values
 +
}}
 +
{{Arg
 +
|type=Angle
 +
|name=angleStart
 +
|desc=Angle to begin from
 +
}}
 +
{{Arg
 +
|type=Angle
 +
|name=angleEnd
 +
|desc=Angle to end at
 +
}}
 +
{{Ret
 +
|type=Angle
 +
|desc=angle
 +
}}
 +
{{Example
 +
|Description=Turns an entity 180 degrees uses lerp over ten seconds
 +
|Code=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)
 
}}
 
}}

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