Garry's Mod Wiki

Revision Difference

Global.LerpAngle#514894

<function name="LerpAngle" parent="Global" type="libraryfunc">⤶ <description>Returns point between first and second angle using given fraction and linear interpolation</description>⤶ <realm>Shared and Menu</realm>⤶ <args>⤶ <arg name="ratio" type="number">Ratio of progress through values</arg>⤶ <arg name="angleStart" type="Angle">Angle to begin from</arg>⤶ <arg name="angleEnd" type="Angle">Angle to end at</arg>⤶ </args>⤶ <rets>⤶ <ret name="" type="Angle">angle</ret>⤶ </rets>⤶ </function>⤶ ⤶ <example>⤶ <description>Turns an entity 180 degrees uses lerp over ten seconds</description>⤶ <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)⤶ </code>⤶ ⤶ </example>