Interpolation/Target
< Interpolation
Jump to navigation
Jump to search
Revision as of 13:19, 4 September 2011 by Nexii Malthus (talk | contribs) (Created page with "{{LSL Header|Interpolation}} {{RightToc|clear:right;}} == Target == {|cellspacing="0" cellpadding="3" border="1" style="border: 1px solid #aaaaaa; margin: 1em 1em 1em 0pt; …")
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials | Interpolation |
Target
Float Target | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Steps float 'Now' closer using float 'Vel' towards 'Target' while clamping between 'Min' and 'Max'. Useful for games, simulations and vehicles. For example keeping realtime track of linear and angular acceleration and velocity of a vehicle. <lsl> float fTarget(float Now, float Target, float Min, float Max, float Vel) { if(llFabs(Target-Now) < Vel) return Target; if(Now < Target) Now += Vel; else Now -= Vel; if(Now < Min) Now = Min; else if(Now > Max) Now = Max; return Now; } </lsl>
Released to Public Domain. By Nexii Malthus
|