Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llSitTarget() with non-zero rotation

Michael Psaltery
Registered User
Join date: 6 Jun 2004
Posts: 57
04-12-2005 22:40
I have a prim on which I'm trying to set a sit target. The prim has rotation of (degrees)<0,90,315> I'm trying to make the sit target so that the av is sitting at <0,0,0> with respect to the world. But NOTHING I try seems to come close to getting it right. Changing any one parameter in increments produces WILDLY different results, and usually the av is sitting at some odd 45-degree angle.

Using: llSitTarget(<0,0,0>,llEuler2Rot(<0,PI/2,PI*7/4>;));

Seems to work some of the time, but it all seems to depend on where the av is standing when you tell it to sit. Sometimes, it sits properly. Sometimes, it sits at a 90-degree angle to where I want it, and on rare occasions it actually says there is no sit targe available. I can click in the exact same place three times in a row, sit, and stand up, and it will sit in a different place/orientation each time. I haven't seen anything in LSL I hate more than the way sit targets are defined. Why not just add a flag to allow setting the target relative to world coordinates???
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
04-12-2005 22:45
... because <0,0,0> is the "default" value that tells an object to shut off the sit target.

Try <0,0,0.1> or another relatively small, but non-zero, sit value. :D

PS: You're referring to <0,0,0> with respect to the object it seems, not the world. Please say this in the future as <0,0,0> with respect to the world would mean you want to sit at the sim's origin. This doesn't seem like what you want to do.

PPS: Please don't bog down the Linden Hotline with simple questions like these. They detract from more important questions. If you simply must post something like this to the Linden Hotline, though... it might be better to use a Subforum. :D
_____________________
---
Michael Psaltery
Registered User
Join date: 6 Jun 2004
Posts: 57
04-13-2005 00:02
The docs all seem to say that you need both zero-vector and zero-rotation to shut off the sit target. It still let's me sit. I can't use <0,0,.01>, because, as stated, I get WILDLY different results. Try it & see. Specifically, this is a cube prim with dimensions <1,1,.75> and a hollow value of .75. Cut at .25 and .75, with a triangle hollow. Rotate it by <0,90,315> and you have a fair decent 1-prim seat... that you can't sit on.

Of course, you want to sit at a location relative to the prim... but it would be very nice to be able to sit with orientation based on world coordinates. The values I should be using are <0,-PI/2,PI/4> to cancel out the <0,PI/2,-PI/4> rotation on the object.... but these DO NOT WORK... you end up sitting at wild angles, often floating a meter away from the object.

If I'm missing something, then hopefully, someone will point it out. But if it's a bug, I certainly think it belongs in the Linden hotline... As for sub-forums, I tried. They wouldn't allow posts.

The problem appears to be with objects that have non-zero x and y-axis rotations, and may or may not have something to do with the hollow and cut attributes. When I use a simple, un-cut prim with zero-rotation (and non-zero offset), the sit target works every time.
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
04-13-2005 07:48
Well, chances are you're missing something... because I know the sit targets I use tend to work just fine.

Unfortunately, the system is probably better explained visually. Try to peg me next time I'm in-world (read as: later today). I'll show you how the sit madness works. :D
_____________________
---
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
04-13-2005 08:43
Hi Michael, I think probably what's happening is that when you are defining the non-zero position, is that the sit target is actually working, but the place where you end up sitting isn't the same as the default position you are expecting. That probably explains your random rotations as the sit target isn't active...

...finding the right position and rotation is a matter of dull trial and error... unless anyone out there has a neat way of finding the exact values you need for the target? (I live in hope :))

/esc
_____________________
http://slurl.com/secondlife/Together
Zalandria Zaius
Registered User
Join date: 17 Jan 2004
Posts: 277
sit positions
04-14-2005 08:03
Documentation must be wrong then.. If you set the position vector to <0,0,0> it ignores the sit target completely. You'll see this if you use llAvatarOnSitTarget().. It will say noone's there.

I did notice one little gliche in your code that could be causing a problem and probably shouldn't even let it compile..

llSitTarget(<0,0,.01>,llEuler2Rot(( 0,-90,-315 )DEG_TO_RAD);

Try that.. see if it works for ya..

I'm typing that from memory so I hope I got all the ('s in the right places..
Michael Psaltery
Registered User
Join date: 6 Jun 2004
Posts: 57
04-14-2005 13:27
Thanks, Zalandria!

FYI, the code I was using was already in radians, so no need to multiply by the DEG_TO_RAD constant. In radians, 2*PI is 360 degrees, PI is 180, PI_BY_TWO (PI/2)
is 90 degrees, PI/4 is 45, and so on.
Walker Spaight
Raving Correspondent
Join date: 2 Jan 2005
Posts: 281
04-15-2005 08:48
Also, it sounds like you're trying to sit the avatar at a point that's within the hollowed part of the cube, probably below the center of gravity, so you might need a negative value in one of those parameters to get your ass down onto the seat :)
_____________________
Read The Second Life Herald: All the fairly unbalanced news we see fit to print.

More news and musings at Walkering.com

"Thank you, Walker Spaight, wherever you are!!"
--Trinity Serpentine
Zalandria Zaius
Registered User
Join date: 17 Jan 2004
Posts: 277
Fool Proof Sit script
04-15-2005 09:46
Alright I think my code above wouldn't quite do what it was supposed to so I tested it and sure enough it doesn't.. Since I'm going to be teaching a class on the sit scripts I figured I'd better learn how to set the suckers no matter what kooky rotation they were at.. So I wrote a little script that so far as I've tested will keep you sitting straight up no matter how you turn the parent prim.. Is it on a parent prim.. would probably need to use llGetLocalRot if you put it in a child prim..

Here goes.. if anyone finds it doesn't work let me know so I don't spread it around SL..


rotation rot;

default
{
state_entry()
{
rotation rot = llGetRot();
rot.x = 0 - rot.x;
rot.y = 0 - rot.y;
rot.z = 0 - rot.z;
llSitTarget(<0, 0.0, 0.5>, rot);


}

}
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
04-16-2005 14:02
Note my responses on this thread.

Zalandria: No, you don't need llGetLocalRot at all if it's in a child prim. llGetRot returns a global rotation for a child prim, so the sit target also works. I tested.

Also, your script there is similar to the one I wrote, which is also identical to doing the following operations:

CODE
rotation rot = llGetRot();
rot.s *= -1;

And:

CODE
rotation rot = ZERO_ROTATION / llGetRot();

Where ZERO_ROTATION = <0,0,0,1>; Note these are different rotations that do the same thing.


Quaternions are fun, aren't they? :D
_____________________
---