Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Orienting a rezzed object so that direction of thrust is the AV's facing

Alex Chadbourne
Laird O' Tamrannoch
Join date: 23 May 2006
Posts: 12
05-11-2008 02:07
Hello!

What I need is a script that will rez an object that is in the same prim as the script itself, and then orient that object to face in the direction that the avatar that it is attached to is facing.

To further clarify, say you had a bowling ball scripted to roll forward on contact with the ground. I want this script to reside inside an attached prim, in which the ball is stored. When touched, the ball hits the ground in front of the avatar, facing in the vector of thrust/motion of the ball.

As it stands right now, no matter which way I face, the object always goes in the same direction.

Any assistance is greatly appreciated!
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
05-11-2008 04:39
For an attached object, llGetRot returns the rotation of the avatar it is attached to. You can then use this to both give an object the right rotation, as well as find vectors pointing forward, up and left, which are often useful as well. So, something like:

rotation rot = llGetRot();
vector fwd = llRot2Fwd(rot);
vector up = llRot2Up(rot);
llRezObject("bowling ball", llGetPos() + fwd - up, fwd * 5.0, rot, 1);

will rez the ball one metre ahead of the av's centre and one metre down, moving forwards at 5m/s.

Note that if the person concerned is in mouselook, this rotation will be as appropriate to their gaze and may be at any angle. If they aren't, it will be "flat", parallel to the XY plane (well, unless they are sitting on a vehicle which has rotated, but let's not get into that).
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
Alex Chadbourne
Laird O' Tamrannoch
Join date: 23 May 2006
Posts: 12
05-11-2008 11:21
Thank you, indeed, Miss Malaprop!

I shall put your advice to use this very day.