Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llMoveToTarget advice, please

Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
11-29-2009 07:17
I'm trying to understand how the damping on llMoveToTarget works. I know that llMoveToTarget(pos,tau); "critically damps a physical object's location to position target over tau seconds," as the lsl wiki puts it, and that llTarget(pos, r); specfies that the at_target event fires when I'm r metres from my target.

What I can't really get a handle on, though, is how to control -- if I can -- the way the object behaves as it approaches its target.

Specifically, how do I control the rate of deceleration? I've got a largish object that moves nicely towards its target but then, rather than slowing down gently and regularly, seems to inch towards the target over the last metre or so. Does the size of r have anything to do with when it starts to slow down? I'm experimenting and getting rather confused.

When I reach my target (a beacon), the object has to remove that target, set a new target from a list it's already read, turn to face the new target and move towards it. It's doing that perfectly well, but it's taking a lot longer than I'd like fiddling around at the target before setting off towards the new one.
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
11-29-2009 07:58
From: Innula Zenovka
Specifically, how do I control the rate of deceleration?

You don't. Or, rather, you don't do it directly.

Usually, the trick is to llMoveToTarget to a spot *past* where you want to be and llTarget the actual spot. Then, in at_target, stop the move or target/move to the next waypoint.

Here's a jira that asks for more control of this stuff: http://jira.secondlife.com/browse/SVC-1479.
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
12-01-2009 06:05
Thanks, Sindy. I am sorry for the delay in replying but I've going nuts trying to get this to work.

How do I calculate -- which I guess is what I need -- a point n metres past my target, measured on my local x axis?

When I do it with non-physical movement, setting my rotation with llRotLookAt() and then saying,
CODE
 float d = llVecDist(llGetPos(),target_pos);
vector my_move_target = llGetPos()+ < d+1,0.0,0.0 > *llGetRot();
llSetPos(my_move_target);
works fine. I turn in the direction I want and then move through my target (set to phantom), facing the way I want to.

But when I try to do the same thing with llMoveToTarget() I end up all over the place. I've tried several permutations -- calling llMoveToTarget() in the at_rot_target event, for example, to make sure I am, in fact, facing the right way -- but no permutation of stopping look ats, stopping moves to rot targets or whatever seems to do it.

I'm sure I'm missing something obvious, but I can't for the life of me see where I'm going wrong.
Susie Chaffe
Registered User
Join date: 13 Mar 2007
Posts: 29
12-02-2009 10:15
I cannot claim this little snippet as my own....but I do use it to for all my ferrys


not_at_target()
{
//A little code to Smoothe movement and reduce damping
float distance = llVecDist(llGetPos(),target);
llMoveToTarget(target,distance*1.0);
}
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
12-02-2009 11:00
From: Innula Zenovka
How do I calculate -- which I guess is what I need -- a point n metres past my target, measured on my local x axis?

/me totally guesses:

vector norm = llVecNorm (targetPos - llGetPos());
float distance = llVecDist (targetPos, llGetPos());

llTarget (targetPos, 0.25); // kick at_target when within 0.25m
llMoveToTarget (norm * (distance * 1.5), 2.0); // move in 2 seconds

edit: I think the math is about right but you'll probably need to tweak the other stuff.

edit: also, beware of https://jira.secondlife.com/browse/SVC-2441 if you're moving to a different .z.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left