Interpolation/Target
Jump to navigation
Jump to search
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
|