Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Physics and Floating in the Air

Bahaar Babcock
Registered User
Join date: 28 Apr 2006
Posts: 9
07-08-2008 11:55
Bear with me as this might be a bit longish.

I've created an object to float above my head and follow me around after I touch it. At first, it wouldn't move at all. Then I did some searching and found about llSetStatus(STATUS_PHYSICS,<TRUE/FALSE>

However, it seems counter-intuitive to me...and still doesn't do what I want it to do. Here's what I mean:

I thought that if it was true, the thing would "obey" the SL laws of physics. When I touch the thing, I set STATUS_PHYSICS to FALSE...but it wouldn't defy gravity and rise to fly above my head. Thinking that maybe it means "defies the laws of physics," I set it to TRUE...and it worked!

But...I now want the thing (on cue) to stop following me and to fall to the ground. So, using my (probably wrong) assumption, I set STATUS_PHYSICS to TRUE...and it won't fall to the ground.

Since my initial attempts, I have tried all sorts of combinations and I cannot seem to get it to workproperly or even coherently.

Can someone explain (1) Which way STATUS_PHYSICS really works, (2) What I need to do to get the thing to stop hovering and to fall to the ground?

Thanks,

---Bahaar Babcock
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
07-08-2008 12:07
you are not telling the whole story. Normally an object in SL stays where you place it in non physics and obey the law of physics when set to physics. There must be some scripting that place it over your head, no?
_____________________
From Studio Dora
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
07-08-2008 12:07
Physical objects will drop to the ground and non-physical ones won't, unless your script is telling them to do something else. Are you also stopping all the scripted motion when you switch the object's physical flag, so that it can do the default thing?
_____________________
Atom Burma
Registered User
Join date: 30 May 2006
Posts: 685
07-08-2008 16:28
Also be weary of setting sculpted prims to physics, it could be that as well. They won't respond as planned at times. And they are not physically the size of the sculpted prim, physically they are a much larger sphere surrounding the prim.
Bahaar Babcock
Registered User
Join date: 28 Apr 2006
Posts: 9
07-08-2008 18:55
Ok, I spent some time paring out all the "other stuff" that my script was doing in order to post just the minimum for this problem.

The goal is this: The object (say a sphere) is just lying on the ground. When you touch it, it gives a bit of instruction and then begins to follow you. If you touch it again it should stop following and fall to the ground. If you say !stop, it should stop following you and fall to the ground.

I know the script isn't perfect, but that's not my goal at this point, I just want it to work.

Also...take note that I've put in some comment-lines that I'll refer to later.

---
string Host_Name = "";
key Host_Key = "";
vector Host_Position;
integer Lost_Counter = 0;

StartSensor()
{
//now start new sensor
llSensorRepeat(Host_Name,Host_Key,AGENT,96,PI,2);
}

default
{
state_entry()
{
llSetStatus(STATUS_PHYSICS, TRUE);
llListen(0,"","","";);
}

on_rez(integer param)
{
llResetScript();
}

listen(integer channel,string name,key id,string message)
{
if(llGetSubString(message,0,5) == "!stop" && name == Host_Name)
{
llSensorRemove();
}
}

touch_start(integer total_number)
{
if(Host_Name == "";)
{
//NOTE 1: In theory, the next line should be FALSE...
llSetStatus(STATUS_PHYSICS, TRUE);
llSay(0,"Wasn't following anyone. Now will follow " + (string)llDetectedName(0));
llInstantMessage(llDetectedKey(0),"Say !stop to make me stop following you.";);
Host_Name = (string)llDetectedName(0);
Host_Key = llDetectedKey(0);
StartSensor();
}
else
{
Host_Name = "";
Host_Key = "";
llSensorRemove();
//NOTE 2: In theory, this should be TRUE
llSetStatus(STATUS_PHYSICS, FALSE);
llSay(0,"Stopped.";);
}
}

sensor(integer total_number)
{
vector Destination = llDetectedPos(0);
Destination.z += 2;
llMoveToTarget(Destination, .1);
Lost_Counter = 0;
}

no_sensor()
{
Lost_Counter++;
if(Lost_Counter >= 10)
{
llSay(0,"Cannot find " + Host_Name + ". Deactivating.";);
llSensorRemove();
llSetStatus(STATUS_PHYSICS, FALSE);
}
}
}
-----

At the comment NOTE 1: You'll see that--if I understand STATUS_PHYSICS, this line should be set to FALSE in order to make it defy gravity. But it doesn't work that way. If I set it to FALSE, the thing just sits there like a lump. However, if I set it to TRUE, it then floats above my head beautifully.

Now we come to comment NOTE 2: Here is where I want gravity to look sharply at the ball and to bring it back to earth. In theory, this should be set to TRUE to make it fall...but it doesn't fall. Thinking that maybe things are working backward (like at NOTE 1), I set it to FALSE...but it still doesn't fall. It stops following nicely enough...it just won't fall down.

So...any ideas now?

---Bahaar Babcock
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
07-09-2008 00:59
I don't see any llStopMoveToTarget();
when you execute llStopMoveToTarget(); and the object is physical it should fall to the ground
_____________________
From Studio Dora
Bahaar Babcock
Registered User
Join date: 28 Apr 2006
Posts: 9
07-10-2008 14:32
Aha! llStopMoveToTarget() was the answer! I'm only a little bit unsure as to WHY I have to issue the command since--in theory--once the object has reached its target destination it should automatically stop...but that's neither here nor there. =*)

Thank you!

---Bahaar Babcock