Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Fixed movement of a prim

Mel Fitzcarraldo
Registered User
Join date: 22 Sep 2005
Posts: 11
06-27-2006 15:38
Greetings!
I have more of a math question than a scripting question, but any adaptation to script would be appreciated also. What I'm after is the ability to move an object approximately 1-1.5m at about 27 degrees angle from whatever its position currently is, and then back again. It has to be along its primary X axis independant of which direction that is pointing. I know this involves some really neat vector math that I have long forgotten :)
I would draw a picture of what I want, but there's no drawing tools in the forum. I can try to elaborate further if needed.

Any help is greatly appreciated!

Also, if anybody has created a good vector and/or rotation library, I would be greatly interested in that also. $L interested as a matter of fact.

Mel
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
06-28-2006 09:59
Well, llRot2Fwd will give you the unit vector that represents the direction in which the object is 'facing' (i.e. the direction in which its local X axis is facing). So if you want to move 1.5m in that direction, I think your new position would be:

CODE
vector newPos = llGetPos() + llRot2Fwd(llGetRot()) * 1.5;


Not sure how the 27 degrees comes into play. Is it moving at 27 degrees to its forward axis? If so, then you'll need to factor that into the rotation I guess. Maybe something like this:

CODE
vector newPos = llGetPos() + llRot2Fwd(llEuler2Rot(<0, 0, 27> * DEG_TO_RAD) * llGetRot()) * 1.5;
Mel Fitzcarraldo
Registered User
Join date: 22 Sep 2005
Posts: 11
06-29-2006 05:32
I need to read the WIKI descriptions more carefully. I think that will work!
Thanks!