Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

hovering/bobbing/floating!

Megg Demina
Registered User
Join date: 11 Jun 2007
Posts: 5
02-05-2009 16:03
Hey there!

I am searching for a script that makes an object bob gently up and down. I want to make lanterns that appear to float/ hover in the air. I hope someone can help! many thanks x
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
02-05-2009 17:44
Well, you may get someone who will write the script for you here, you'll most likely get told to go to the product wanted thread. I'm not going to write the script, but if you want to take a shot at it, make the object physical, and use llSetBuoyancy(1.0) which will make the physical object "float". You'll probibly want to make it phantom too, or else someone bumping it will cause the object to go flying... as for bobbing, several ways to do this, apply small impulses.. or you could even try a timer that changes the buoyancy of the object ever so slightly. You'll also probibly want to set an internal box for the object to stay in, incase someone grabs the thing, being physical and all.
Kri Ayakashi
Registered User
Join date: 11 Apr 2007
Posts: 3
02-06-2009 01:39
a simple idea to get you started:

From: someone

vector spawn_point;
vector float_amount = <0.0, 0.0, 0.3>;
integer float_dir = 1;

default
{
state_entry()
{
spawn_point = llGetPos();
llSetTimerEvent(1.0);
float mass = llGetMass(); // mass of this object
float gravity = 9.8; // gravity constant
llSetForce(mass * <0,0,gravity>, FALSE); // in global orientation
}

on_rez(integer param)
{
spawn_point = llGetPos()+<0.0, 0.0, 1.0>;
llSetTimerEvent(1.0);
}

timer()
{
if(float_dir==1)
float_dir = -1;
else
float_dir = 1;
float_amount *= float_dir;
llMoveToTarget(spawn_point+float_amount, 1.0);
}

}