Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

move object along local x axis?

paulie Femto
Into the dark
Join date: 13 Sep 2003
Posts: 1,098
04-29-2005 17:18
I'm trying to use llSetPos to move an object along the object's local X or Y axis. llSetPos only seems to move the object along the world x and y axis.
_____________________
REUTERS on SL: "Thirty-five thousand people wearing their psyches on the outside and all the attendant unfettered freakishness that brings."
Kali Dougall
Purple and Spikey
Join date: 5 Feb 2005
Posts: 98
04-29-2005 17:36
FYI, llSetPos is neither local nor global. It just goes to the coordinates you give it. What you need is a vector offset along the X axis turned into local movement:

CODE
vector movement = <1, 0, 0>; // This is the movement along the X axis.

vector localMovement = movement * llGetRot(); // This is the key line for making the above movement local rather than global.

vector currentPos = llGetPos(); // Current position.

llSetPos(currentPos + localMovement); // Move the specified distance along the local X axis.
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
04-29-2005 19:02
Actually, llSetPos is "global", the coordinates are those of the sim, not of the object. :)
_____________________
Kali Dougall
Purple and Spikey
Join date: 5 Feb 2005
Posts: 98
04-29-2005 19:41
Oh, true enough. I thought he meant he was applying an offset and expecting it to automatically be local movement or something. I probably misunderstood. In any case, that code sample will do it. :)
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
04-30-2005 21:45
Hi paulie,

Use rotations, if you want to move objects along the local axis.

llSetPos(llGetPos() + (<x,y,z> * llGetRot()));

"We're multiplying a vector times a rotation. Rotations are in
quaternions, but it's easy to remember for now that when you multiply a vector times llGetRot(), it puts the vector in the local frame of the object."

Jeffrey Gomez told me so. I didn't uderstand it at all though. :p
I just wanted to quote this. :D

Edit: Sorry, I faild in URL Link...
_____________________
:) Seagel Neville :)
paulie Femto
Into the dark
Join date: 13 Sep 2003
Posts: 1,098
Thanks!
05-02-2005 11:00
Thanks, everyone!
_____________________
REUTERS on SL: "Thirty-five thousand people wearing their psyches on the outside and all the attendant unfettered freakishness that brings."