Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sitting and making AV face a certain direction.

Wyatt Burton
Registered User
Join date: 11 Jan 2007
Posts: 49
12-16-2007 17:16
I want to make the avatar sit and rotate towards a particular direction. I put this code in the prim that the AV sits on.

default
{
state_entry()
{
llSetText("Sit",<255,255,255>,1.0);
llSetSitText("Sit";);
llSitTarget(<0,0,0>, llEuler2Rot(<0,0,180>;));
}

}

Of course this doesn't work since it is always rotating 90o. Is there a way to make the AV sit but face a certain direction?
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
12-16-2007 19:14
"Face a certain direction" locally or globally? Locally is easy, just pass the desires direction as a rotator to llSetSitTarget. But note that llEuler2Rot expects angles measured in radians, not degrees. PI rad == 180 deg.

For global directions, you'll have to divide the desired rotation by the object's rotation.
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
12-16-2007 23:40
llSetSitTarget requires a NON ZERO vector to take effect.

llSitTarget(<0,0,0>,<some rotation>;); will NOT work.

llSitTarget(<0,0,0.01>,<some rotation>;); will work.
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
12-17-2007 03:02
D'oh! That one slipped right past me. That's what I get for posting in a state of near-unconsciousness.
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
12-17-2007 10:18
The rotation should be in radians, not degrees.

180*DEG_TO_RAD
_____________________
So many monkeys, so little Shakespeare.
Okiphia Rayna
DemonEye Benefactor
Join date: 22 Sep 2007
Posts: 2,103
12-17-2007 10:21
From: Lee Ponzu
The rotation should be in radians, not degrees.

180*DEG_TO_RAD


or

llEuler2Rot(0,0,PI_BY_TWO);
EDIT::
wait pi by two is 180 isnt it? SO..PI

lol
_____________________
Owner of DemonEye Designs Custom Building and Landscaping
Owner and Blogger, Okiphia's Life
http://okiphiablog.blogspot.com/
Wyatt Burton
Registered User
Join date: 11 Jan 2007
Posts: 49
12-17-2007 15:52
From: Squirrel Wood
llSetSitTarget requires a NON ZERO vector to take effect.

llSitTarget(<0,0,0>,<some rotation>;); will NOT work.

llSitTarget(<0,0,0.01>,<some rotation>;); will work.



It helps knowing about the NON_ZERO vector. However I want to know if I my AV sits on say a chair I make, how do I tell it (or the chair) to always sit correctly (e.g. AVs back facing back of chair) no matter which way the chair is facing.

Is the llSitTarget() enough or do I need to always take into account chair orientation.
Cristalle Karami
Lady of the House
Join date: 4 Dec 2006
Posts: 6,222
12-17-2007 16:17
Try getting the local rotation or the chair first using llGetLocalRot, store this in a variable and then use that for the rotation.
_____________________
Affordable & beautiful apartments & homes starting at 150L/wk! Waterfront homes, 575L/wk & 300 prims!

House of Cristalle low prim prefabs: secondlife://Cristalle/111/60

http://cristalleproperties.info
http://careeningcristalle.blogspot.com - Careening, A SL Sailing Blog
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
12-17-2007 19:05
This is getting a little confused. The rotation specified in llSitTarget is relative to the prim, as Deanna mentioned. So the script doesn't need to adjust that rotation when the chair rotates in order to keep the avatar facing the same direction relative to the chair.

(It *would* have to do that, however, if the avatar was always supposed to face East, say. Or if the prim containing the llSitTarget rotated locally relative to the rest of the chair but the avatar's rotation was to remain constant relative to the rest of the chair rather than to the prim on which he's sitting. But this doesn't seem to be either of those rather special cases.)

You can see this for yourself when you adjust a poseball, for example. When your avatar sits on the poseball it adopts the rotation specified in the poseball's llSitTarget. When you rotate the poseball, your avatar rotates with it, while the llSitTarget remains the same.
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
12-18-2007 00:01
sit target position and rotation are offsets which add to the objects current position and rotation. No need to worry about the object position/rotation.