// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Frame-independent approach to a target // Not compiled or tested in-world // Setup: Put in a spare prim you own. Touch to simulate one second using ten small steps and four larger steps. // Stop / restore: Disable or remove the script. It only reports to its owner and does not change prim properties. Reset clears its temporary state. // Notes: The response constant is positive inverse-seconds. The constant target is important: changing targets between samples can produce different paths. // License: see LICENSE in this distribution. // Original Incoprea example. MIT. Owner-only calculation; no scene changes. float approach(float value, float target, float response, float elapsed) { if (elapsed <= 0.0) return value; if (response <= 0.0) return value; float weight = 1.0-llPow(2.718281828,-response*elapsed); return value+(target-value)*weight; } default { touch_start(integer detectedCount) { if (llDetectedKey(0) != llGetOwner()) return; float a = 0.0; float b = 0.0; integer i; for (i=0; i<10; ++i) a=approach(a,10.0,3.0,0.1); for (i=0; i<4; ++i) b=approach(b,10.0,3.0,0.25); llOwnerSay("10 x 0.1 seconds: "+(string)a+"; 4 x 0.25 seconds: "+(string)b); } changed(integer change) { if (change & CHANGED_OWNER) llResetScript(); } }