Make things move
Float Gentle Bobbing
Makes a prim gently float up and down using a smooth sine wave motion.
Goes ina prim
Setup3 to set
Code45 lines
Open toOpen to everyone
What it does
The script moves a prim vertically in a smooth, continuous wave pattern. It uses a sine curve to create natural bobbing motion that loops endlessly without jarring changes in direction.
What you can build with it
You could build floating platforms, gently rising and falling chandeliers, bobbing buoys or water lily pads, or levitating decorative objects. Works well for ambient motion in builds that should feel alive and natural.
How to use it
1
Drop this script into a prim.
2
Adjust AMPLITUDE (0.15 default) to control how far up and down it moves, in meters.
3
Adjust PERIODE (4.0 default) to control how fast it bobs, in seconds per cycle.
4
The prim will begin bobbing immediately and reset its starting position each time it rezzes.
Settings you can change
3Edit these at the top of the script. Everything works on the defaults · change them only when you need to.
AMPLITUDE
Height of the bobbing motion in meters. Smaller values are more subtle. Default 0.15.
·
PERIODE
Duration of one complete up-and-down cycle in seconds. Larger values are slower. Default 4.0.
·
FPS
Updates per second. Higher values create smoother motion but use more script resources. Default 20.0.
·
// Float Schweben - sanftes Schweben/Schwingen fuer einen Prim
// Bewegt den Prim weich auf und ab per Sinus-Kurve.
// Laeuft eigenstaendig, kann neben anderen Skripten (z.B. Licht) im selben Prim liegen.
// ---- Einstellungen ----
float AMPLITUDE = 0.15; // Wie weit hoch/runter (in Metern). Kleiner = subtiler.
float PERIODE = 4.0; // Dauer einer kompletten Schwingung in Sekunden. Groesser = langsamer.
float FPS = 20.0; // Aktualisierungen pro Sekunde. Hoeher = glatter, mehr Last.
// ---- intern ----
vector gBasis; // Ausgangsposition (lokal)
float gT; // Zeitzaehler
init()
{
gBasis = llGetLocalPos();
gT = 0.0;
llSetTimerEvent(1.0 / FPS);
}
default
{
state_entry()
{
init();
}
on_rez(integer p)
{
init();
}
timer()
{
gT += 1.0 / FPS;
// Sinus schwingt weich zwischen -1 und +1, kein hartes Auf-Ab
float offset = AMPLITUDE * llSin(gT * TWO_PI / PERIODE);
vector p = gBasis;
p.z += offset;
llSetPos(p);
// Zeit zuruecksetzen, damit sie nicht ewig waechst
if (gT > PERIODE) gT -= PERIODE;
}
}
Copy it, make a new script inworld, paste over what is there and save. Nothing here phones home.