Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

moving on a set path

Boris Eebus
Registered User
Join date: 8 Feb 2008
Posts: 45
05-13-2008 09:31
I've tried this - it moves 10m turns and then does nothing - I want it to move 10m turn move 2m turn, move 20m turn, move 2m turn. so it ends back at the beginning. how do i alter this to work???

Thanks


integer targetID;


default
{
touch_start( integer total_number )
{
// Become a physical object
llSetStatus(STATUS_PHYSICS, TRUE);
llSetPrimitiveParams([PRIM_PHANTOM, TRUE]);

//llWhisper( 0, "we're on our way" );

// destination is ten meters above our current position

vector destination1 = llGetPos() + <20, 0, 0>;

// how close is close enough
float range = 0.5;

// Ask to be informed whether we're there or not
targetID = llTarget( destination1, range );

// Start moving towards the destination

llMoveToTarget( destination1, 10 );
}

not_at_target()
{
// We're not there yet.
//llWhisper(0, "Still going";);
}

at_target( integer number, vector targetpos, vector ourpos )
{
//llSay(0, "We've arrived!";);

// Stop notifications of being there or not

llTargetRemove(targetID);

// Stop moving towards the destination
llStopMoveToTarget();



// Become non-physical
llSetStatus(STATUS_PHYSICS, FALSE);

vector eul = <0,0,-180>; //45 degrees around the z-axis, in Euler form
eul *= DEG_TO_RAD; //convert to radians
rotation quat = llEuler2Rot(eul); //convert to quaternion
llSetRot(quat); //rotate the object





// Become a physical object
//llSetStatus(STATUS_PHYSICS, TRUE);
//llSetPrimitiveParams([PRIM_PHANTOM, TRUE]);

//llWhisper( 0, "we're on our way" );

// destination is ten meters above our current position

vector destination2 = llGetPos() + <0, 2, 0>;

// how close is close enough
float range = 0.5;

// Ask to be informed whether we're there or not
targetID = llTarget( destination2, range );

// Start moving towards the destination

llMoveToTarget( destination2, 10 );
}

not_at_target()
{
// We're not there yet.
//llWhisper(0, "Still going";);
}

at_target( integer number, vector targetpos, vector ourpos )
{
//llSay(0, "We've arrived!";);

// Stop notifications of being there or not

llTargetRemove(targetID);

// Stop moving towards the destination
llStopMoveToTarget();



// Become non-physical
llSetStatus(STATUS_PHYSICS, FALSE);

vector eul = <0,0,-180>; //45 degrees around the z-axis, in Euler form
eul *= DEG_TO_RAD; //convert to radians
rotation quat = llEuler2Rot(eul); //convert to quaternion
llSetRot(quat); //rotate the object





}
}
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
05-13-2008 12:45
the way to do it is to create a list with your destination waypoints like this...

CODE

vector startPos = llGetPos();
list waypoints = [<10,0,0>, <0,2,0>];

then read each waypoint from the list, add to your current position, then set the target and call llMoveToTarget(), then when at_target() is triggered, read the next waypoint from the list, and remove the old target, set the new target, and call llMoveToTarget() again.
Renato Surtees
Registered User
Join date: 19 Jan 2007
Posts: 7
note card easier?
05-13-2008 18:15
wouldn't using a notecard with the destinations be just as effective? or does that cause more Lag. Cause you lost me on the

then read each waypoint from the list, add to your current position, then set the target and call llMoveToTarget(), then when at_target() is triggered, read the next waypoint from the list, and remove the old target, set the new target, and call llMoveToTarget() again.
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
05-13-2008 21:18
From: Renato Surtees
wouldn't using a notecard with the destinations be just as effective? or does that cause more Lag. Cause you lost me on the

then read each waypoint from the list, add to your current position, then set the target and call llMoveToTarget(), then when at_target() is triggered, read the next waypoint from the list, and remove the old target, set the new target, and call llMoveToTarget() again.


Yeah, a notecard works fine. as a matter of fact, the way my device works is that you set the object where you want a waypoint, click "set waypoint" on a menu, then move the object to the next point, and repeat the process until you're finished. Then, it emails the vector list to my email address, where I copy the waypoints, and paste to a notecard, and the script then reads the waypoints into a list on state_entry. I used to write the waypoints to the object description, but that's bunk now that LL hacked object descriptions down from 8k to 127 bytes :(
Renato Surtees
Registered User
Join date: 19 Jan 2007
Posts: 7
05-28-2008 09:48
ohh your object available for this ?i like that would save me a load of work.