Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

calculating steps for llMoveToTarget

Lulu Pink
Registered User
Join date: 30 Sep 2006
Posts: 18
05-09-2008 17:05
I want to make a simple tour balloon and approached this to have smooth but not wild movements with as i thought the simplest way:
I have 7 stop points on my tour.
then i move from one to the other with llMoveToTarget(nextStop, 1.5)
Well, all fine if the stops are within a 60m distance(which is about how far llMoveToTarget moves i think) but of course they are not.
So rather than adding points to pass i thought it should be possible to calculate them...
But either my math isnt enough or i dont see it yet.
This is a try approach... it doesnt work!

vector vDest1 = <45,230,20>;
vector vDest2 = <95,180,40>;
vector CalculateNextStep(vector next)
{
float dist;
dist = llVecMag(next - vDest1);
while(dist > 60)
dist = dist - dist/2;
next = llVecNorm(next)*dist;
next = next * llVecMag(next);
return next;
}
default
{
state_entry()
{
llSay(0,(string)CalculateNextStep(vDest2));
}
}

I am sure there is a way to calculate this ... please any hints appreciated MUCH :))

or just tell me to make a "real" balloon as vehicle, i just thought my approach is simlper and easier ;)

Lulu
Lulu Pink
Registered User
Join date: 30 Sep 2006
Posts: 18
05-09-2008 17:25
ok, i think i got it just now lol.
for all who like this idea:
here's the function that calculates a vector pointing to the next more than 60m away:

vector CalculateNextStep(vector start, vector next)
{
float dist;
vector temp = next - start;
dist = llVecMag(next - start);
while(dist > 60)
{
dist = dist - dist/2;
}
next = start + llVecNorm(temp)*dist;
return next;
}

Lulu