Smooth transition between two angles

Is there a way to transition between two different angles (like the players eye angles) so they don’t suddenly snap to the desired angle?

math.Approach

**[G.LerpAngle

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=G.LerpAngle)**

could you give an example on how i would use this to smooth a transition between 2 angles?

[lua]local fraction = ( CurTime() - StartTime ) / Length;
local curAngle = LerpAngle( fraction, startAngle, targetAngle );[/lua]

That’s just what I need, but its outputting unexpected angles, can you please explain what StartTime and Length are? I assume StartTime is the time initiated, but I don’t get length.
Thanks for the help so far.

Length is the time interval in which the angle should transition. LerpAngle screws up when fraction goes out of range. Clamp it:

[lua]math.Clamp( fraction, 0, 1 );[/lua]

Thank you Nevec! Took a little tweaking to know where to put the parts but it’s all working now! Thanks again!