|
Xero Havercamp
Registered User
Join date: 28 Mar 2006
Posts: 5
|
05-25-2006 05:47
Hello all, I am working with llMoveToTarget and am moving a distance greater then 60 meters and have a mental block on how to incriment my vector by 60 meters at a time? If I am at <20,20,20> and want to move to <128,128,128> I can use llVecDist to determine that I am 108m away from my target destination, however if i do this: llMoveToTarget(<128,128,128>  ; this will fail as it excceds the 60m limit imposed by this method. So the question is, how to add incrimentally add 60 meters to teh first vector to get to the destination target? Thanks everyone.
|
|
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
|
05-25-2006 07:03
I think this is the general idea of what you want: moveToTarget( vector dest ) { vector here = llGetPos(); vector diff = dest - here; integer nJumps = (integer)(llVecMag(diff)/60)+1; vector normDiff = llVecNorm(diff); integer i; for ( i = 1 ; i < nJumps ; ++i ) { llMoveToTarget( here + normDiff * i * 60 , .4 ); llSleep( .5 ); } llMoveToTarget( dest , .4 ); llSleep( .5 ); }
It should compile, but I haven't tested it in-world.
|