Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

moving an object in a square pattern

Sebastiaan Siegel
Registered User
Join date: 2 Feb 2007
Posts: 18
03-26-2007 03:46
Hi, I'm trying to get an object to move in a square pattern, but for some reason its not working (as usual). Im using 4 vectors and the llMoveToTarget function, but nothing is happening. Would somebody please be so kind to point out what wrong with this script?

- what it should do: move in a squarelike patern
- what it's doing: noting :P

CODE

vector home;
vector destination1;
vector destination2;
vector destination3;


startup()
{
llSetHoverHeight(0.5, 0, 1);
vector pos = llGetPos();
llSetStatus(STATUS_ROTATE_Z, TRUE);
llSetStatus(STATUS_ROTATE_X, FALSE);
llSetStatus(STATUS_ROTATE_Y, FALSE);
llSetStatus(STATUS_PHYSICS, TRUE);

}

default
{
state_entry()
{
startup();
vector home = llGetPos();
vector destination1 = home + <-5, 0, 0>;
vector destination2 = home + < 0, -5 ,0>;
vector destination3 = home + < 5, 0, 0>;


//llOwnerSay((string)home);
}

touch_start(integer total_number)
{
llMoveToTarget(destination1, .3);
//llSleep(5);
llMoveToTarget(destination2, .3);
//llSleep(5);
llMoveToTarget(destination3, .3);
//llSleep(5);
llMoveToTarget(home, .3);
}
}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-26-2007 04:17
From: Sebastiaan Siegel
Hi, I'm trying to get an object to move in a square pattern, but for some reason its not working (as usual). Im using 4 vectors and the llMoveToTarget function, but nothing is happening. Would somebody please be so kind to point out what wrong with this script?

- what it should do: move in a squarelike patern
- what it's doing: noting :P

CODE

vector home;
vector destination1;
vector destination2;
vector destination3;


startup()
{
llSetHoverHeight(0.5, 0, 1);
vector pos = llGetPos();
llSetStatus(STATUS_ROTATE_Z, TRUE);
llSetStatus(STATUS_ROTATE_X, FALSE);
llSetStatus(STATUS_ROTATE_Y, FALSE);
llSetStatus(STATUS_PHYSICS, TRUE);

}

default
{
state_entry()
{
startup();
vector home = llGetPos();
vector destination1 = home + <-5, 0, 0>;
vector destination2 = home + < 0, -5 ,0>;
vector destination3 = home + < 5, 0, 0>;


//llOwnerSay((string)home);
}

touch_start(integer total_number)
{
llMoveToTarget(destination1, .3);
//llSleep(5);
llMoveToTarget(destination2, .3);
//llSleep(5);
llMoveToTarget(destination3, .3);
//llSleep(5);
llMoveToTarget(home, .3);
}
}


Your destinations are all going to be zero as you are masking the global variables with locals in the state_entry event handler. Try this:

CODE

state_entry()
{
startup();
home = llGetPos();
destination1 = home + <-5., 0., 0.>;
destination2 = home + < 0., -5. ,0.>;
destination3 = home + < 5., 0., 0.>;


//llOwnerSay((string)home);
}
Sebastiaan Siegel
Registered User
Join date: 2 Feb 2007
Posts: 18
03-26-2007 05:16
thanks that seems to work :)

i also added the following echoes.

llOwnerSay((string)home);
llOwnerSay((string)destination1);
llOwnerSay((string)destination2);
llOwnerSay((string)destination3);

home is set to "<0,0,0>"
while the other vectors all have positive values, how is this possible?
Shouldnt home echo the starting location???
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-26-2007 05:30
From: Sebastiaan Siegel
thanks that seems to work :)

i also added the following echoes.

llOwnerSay((string)home);
llOwnerSay((string)destination1);
llOwnerSay((string)destination2);
llOwnerSay((string)destination3);

home is set to "<0,0,0>"
while the other vectors all have positive values, how is this possible?
Shouldnt home echo the starting location???



It should do, but check you have the corrected verison of my post. I originally mis-edited and home was left locally defined in state entry.
Sebastiaan Siegel
Registered User
Join date: 2 Feb 2007
Posts: 18
03-26-2007 06:10
more weirdness, it's moving, but not quite all right.
the code im currently using is:

CODE

vector home;// = <550,119,74>;
vector destination1;
vector destination2;
vector destination3;
vector destination4;


startup()
{
llSetHoverHeight(0.5, 0, 1);
vector pos = llGetPos();
llSetStatus(STATUS_ROTATE_Z, TRUE);
llSetStatus(STATUS_ROTATE_X, FALSE);
llSetStatus(STATUS_ROTATE_Y, FALSE);
llSetStatus(STATUS_PHYSICS, TRUE);

}

default
{
state_entry()
{
startup();
vector home = llGetPos();
destination1 = home + <-5., 0., 0.>;
destination2 = home + <-5., -5. ,0.>;
destination3 = home + < 0., -5., 0.>;
//destination4 = home +


llOwnerSay((string)home);
}

touch_start(integer total_number)
{
llOwnerSay((string)home);
// llOwnerSay((string)destination1);
// llOwnerSay((string)destination2);
// llOwnerSay((string)destination3);

llSleep(1.1);
llLookAt(destination1, .1, 1);
llMoveToTarget(destination1, 2);
llSay(0,"een");
llSleep(1.1);
llLookAt(destination2, .1, 1);
llMoveToTarget(destination2, 2);
llSay(0,"twee");
llSleep(1.1);
llLookAt(destination3, .1 ,1);
llMoveToTarget(destination3, 2);
llSay(0,"drie");
llSleep(1.1);
llLookAt(home, .1 ,1);
llMoveToTarget(home, 2);
llSay(0,"vier");
llStopMoveToTarget();
llStopLookAt();
llSay(0,"stopped");

}
}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-26-2007 06:40
Your state_entry code is the incorrect one I posted and then corrected.
it declares vector home locally which will be preventing the global variable from being updated.

CODE

state_entry()
{
startup();
vector home = llGetPos();
destination1 = home + <-5., 0., 0.>;
destination2 = home + <-5., -5. ,0.>;
destination3 = home + < 0., -5., 0.>;
//destination4 = home +


llOwnerSay((string)home);
}

I corrected this in the orginal posting but obviously after you had already taken a copy of the code.
CODE

state_entry()
{
startup();
home = llGetPos();
destination1 = home + <-5., 0., 0.>;
destination2 = home + <-5., -5. ,0.>;
destination3 = home + < 0., -5., 0.>;
//destination4 = home +


llOwnerSay((string)home);
}
Robustus Hax
Registered User
Join date: 4 Feb 2007
Posts: 231
03-26-2007 09:34
Ive found the RotLookat and Look at are still behaving bad there was a few days that it was reversed ad working fine but now certain directions for me, anyway the object will not rotate correctly.