Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llMoveToTarget() limit

jadz0r Conover
Registered User
Join date: 18 Jun 2006
Posts: 9
07-19-2006 10:19
Hello.

I have been working on some sort of multigadget and I stumbled across with a very nasty problem. On an attached item, I can't move any farther than 65m with llMoveToTarget() like the wiki says. The immediate solution would be to use a loop such as

while (llGetPos() != targetposition) {
llMoveToTarget(targetposition, 0.1);
}

However, for some reason, this makes the script pretty much freeze into that loop. Is there another way of moving an avatar with an attachment farther than 65m without halting the script?

Thanks in advance.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
07-19-2006 10:51
while(llVecDist(llGetPos(), destination) > 0.1))
{
llMoveToTarget(destination, 0.1);
}

Or similar should work. Because it's virtually impossible for the two vectors to exactly equal each other you set a suitable fine arrival value and when it's less than that you drop out. 0.1m is usually a pretty good bet, 1m might be OK too.
_____________________
Eloise's MiniMall
Visit Eloise's Minimall
New, smaller footprint, same great materials.

Check out the new blog
jadz0r Conover
Registered User
Join date: 18 Jun 2006
Posts: 9
07-19-2006 10:54
Thanks a lot!
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
07-19-2006 11:30
From: jadz0r Conover
However, for some reason, this makes the script pretty much freeze into that loop. Is there another way of moving an avatar with an attachment farther than 65m without halting the script?

If you mean 'halting script' in sense of ignoring any events until destination is reached then something like may do the trick:
CODE

vector destination;
integer travelling = FALSE;

travel() {

vector remaining = destination - llGetPos();
float distance = llVecMag( remaining );
if( distance < 60.0 ) llMoveToTarget( destination, 0.1 );
else {

llMoveToTarget( llGetPos() + ( 60.0 / distance * remaining ), 0.1 );
}
}

default {

on_rez( integer Parameter ) { llResetScript(); }

touch_start(integer total_number) {

destination = llGetPos() + <0.0, -100.0, 25.0>;
llOwnerSay( "On my merry way to " + (string)destination );
travelling = TRUE;
travel();
}

moving_end() {

if( travelling == TRUE ) {

if( llVecMag( llGetPos() - destination ) > 0.1 ) {

llOwnerSay( "Not yet there..." );
travel();
}
else {

llOwnerSay( "There XD" );
llStopMoveToTarget();
travelling = FALSE;
}
}
}
}