Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to Move an Object Forward..Relatively

Grim Enigma
Registered User
Join date: 14 Nov 2005
Posts: 35
12-31-2005 16:34
Phantom Vehicle, trying to make it go forward..Even if its been rotated.

I know the scripting for CONTROL_FWD isn't right. I'm just not sure how to go about making it always go forward.


CODE


if(level & CONTROL_FWD)
{
llSetPos(llGetPos() + <2, 0, 0>);
}
if(level & CONTROL_BACK)
{
llSetPos(llGetPos() + <-2, 0, 0>);
}
if(level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT))
{
llSetRot(llGetRot()* llEuler2Rot( <0, 0, -10 * DEG_TO_RAD> ));

}
if(level & (CONTROL_LEFT|CONTROL_ROT_LEFT))
{
llSetRot(llGetRot()* llEuler2Rot( <0, 0, 10 * DEG_TO_RAD> ));
}
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
12-31-2005 17:18
From: Grim Enigma
Phantom Vehicle, trying to make it go forward..Even if its been rotated.

I know the scripting for CONTROL_FWD isn't right. I'm just not sure how to go about making it always go forward.


Slightly offhand but I believe it's.. llSetPos(llGetPos() + ( <2,0,0> * llGetRot() );
Grim Enigma
Registered User
Join date: 14 Nov 2005
Posts: 35
12-31-2005 17:56
Get a syntax error with that.. I think Rot2Fwd needs to be used here... I'm just not sure how.
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
12-31-2005 17:58
+ 2 * llRot2Fwd(llGetRot()) I would think... or is there a shortcut?
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
12-31-2005 18:41
Yumi's is my preferred method, the syntax error is likely because there is a closed bracket missing from the end
Grim Enigma
Registered User
Join date: 14 Nov 2005
Posts: 35
12-31-2005 19:24
That was it.... worked like a charm. Thank you.
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
01-01-2006 08:37
Now I did not know that you could multiply a vector by a rotation to rotate the vector. That's useful information. I've been doing it manually.