Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Physics, mass, and inertia, oh my

Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
06-06-2009 00:51
Today I was asked to build a table and chairs that hover on a jet or jets. I've never dealt with physical items much before; I've never had much call to, and whenever I play with them I usually do something stupid like accidentally deleting my build platform and then have to search for them all over the ground below. :P

Anyhoo, I started with a chair. I found the following script in one of the threads here; I can't remember who the author was just now, but many thanks to them. I only had to tweak the values a little. :)

CODE


integer up = TRUE;

default
{
touch_start(integer total_number)
{
llSetStatus(STATUS_PHYSICS, TRUE);
llSetTimerEvent(1.0);
}
timer()
{
if(up)//this reads as: if(up == TRUE)
{
llSetBuoyancy(1.08);
up = FALSE;
}
else
{
llSetBuoyancy(0.9);
up = TRUE;
}
}
}


This makes my chair do a nice job of hovering in place, while smoothly bobbing up and down just the right amount, but it tended to tip over. So, I fixed this "mechanically" by hanging a big (relatively speaking) "ballast" prim off the bottom, and texturing it with alpha. No more tippage.

However, whenever I give the chair a little shove, say by hopping off, it drifts laterally.

My main question is this: Since I don't want or need the chair to move laterally at all, I could probably solve this problem mechanically again by using boundary prims. Just surround it with a couple of cut and hollowed prims that are also alpha-textured, and it won't be able to move laterally, right? Or, do you folks think it would be better to take care of this issue from within the script, and if so, how?

Second question: Do avatars add at all to the mass of a physical item when they sit on it? So far it doesn't seem they do, but all this is doing is bobbing up and down, and I'd rather be sure about this for future reference. Obviously they can affect physical items by getting off, do they also affect them by being on?

Third, there wouldn't be any "friction" if I did use boundary prims, right?

Fourth, since my ballast prim stabilized my chair, does it also add mass? It doesn't seem to. Perhaps "mass" is the wrong term, but I hope you know what I mean. I seem to be discovering that SL physics are a bit different to RL physics. :)

Fifth, how can I turn this thing off, and have it settle back to the ground, prim surface, or whatever? I tried a couple of ways, even got one of them to compile, but it didn't do anything. I always have trouble with if/else calls in this regard.

Thanks in advance for your help. Oh, and please speak S-L-O-W-L-Y and don't assume I know anything at all; when it comes to scripts, I'm a lot dumber than I look. :)
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
06-06-2009 03:30
From: Basement Desade
This makes my chair do a nice job of hovering in place, while smoothly bobbing up and down just the right amount, but it tended to tip over. So, I fixed this "mechanically" by hanging a big (relatively speaking) "ballast" prim off the bottom, and texturing it with alpha. No more tippage.
The way to make it not tip is with this:
llSetStatus( STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
This will fix tipping on all axis. You just edit it to serve your need
_____________________
From Studio Dora
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-06-2009 03:59
I'd leave at least on axis unlocked (probably Z in this scenario) so that it's not stuck in the same facing (you can grab to rotate)... perhaps not, just depends on your application.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
06-06-2009 04:45
So which is most efficient regarding sim performance? My ballast fix, or a script fix?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-06-2009 05:41
From: Basement Desade
So which is most efficient regarding sim performance? My ballast fix, or a script fix?

script axis locking, definitely... doesn't generate additional collisions or require hidden parts
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
06-06-2009 18:35
You might also try a llMoveToTarget() (or two), either to actually do the bobbing or just to pull the chair back into place if it drifts a certain distance from its starting position.
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
A bit confused
06-07-2009 09:38
From: Hewee Zetkin
You might also try a llMoveToTarget() (or two), either to actually do the bobbing or just to pull the chair back into place if it drifts a certain distance from its starting position.



Hmm. I looked llMoveToTarget up on the wikis, and what I found was mostly aimed at having an object follow you around.

I DID find this, which seems to relate to my problem, but is as clear as mud, at least to me: "Q: Is there a way of moving an object physically like llMoveToTarget on local axis?
A: try llMoveToTarget(llGetPos() + localaxisoffset * llGetRot(), damp) - Merlin Alphabeta"

Is localaxisoffset an integer value? And I don't know what to make of the asterisk. There was no corresponding footnote, nor do I believe it belongs in the code. Or does it? Then there is damp, which seems to be there to damp rot, but how? Is this an integer value?
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
I tried this...
06-07-2009 09:58
But it doesn't do anything regarding keeping the object in place:

CODE

integer up = TRUE;


default
{
touch_start(integer total_number)
{
llSetStatus(STATUS_PHYSICS, TRUE);
llSetTimerEvent(1.0);


}
timer()
{
if(up)//this reads as: if(up == TRUE)
{
llSetBuoyancy(1.08);
vector pos = llGetPos();
llMoveToTarget(pos,0.01);
up = FALSE;
}
else
{
llSetBuoyancy(0.9);
vector pos = llGetPos();
llMoveToTarget(pos,0.01);
up = TRUE;
}
}
}
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
06-07-2009 10:09
From: Basement Desade

I DID find this, which seems to relate to my problem, but is as clear as mud, at least to me: "Q: Is there a way of moving an object physically like llMoveToTarget on local axis?
A: try llMoveToTarget(llGetPos() + localaxisoffset * llGetRot(), damp) - Merlin Alphabeta"

Is localaxisoffset an integer value? And I don't know what to make of the asterisk. There was no corresponding footnote, nor do I believe it belongs in the code. Or does it? Then there is damp, which seems to be there to damp rot, but how? Is this an integer value?


Translating ....... Merlin means "Move the object in the following way, using the standard function llMoveToTarget .. Get the object's current position (a vector) and add to that an offset vector (i.e., the amount and direction you want to move) multiplied by the object's current rotation (i.e., its orientation in space) and apply a damping factor (a floating point number) to define how quickly it moves there."
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
06-07-2009 15:44
You original code allows the object to bounce up and down slightly. Most likely the same sort of feel would be accomplished by setting buoyancy to 1.0 and using llMoveToTarget() between two points, one slightly higher than the other. That will also apply a force toward the object's starting point if it is moved horizontally.