Wrestling With llMoveToTarget
|
|
Bodhisatva Paperclip
Tip: Savor pie, bald chap
Join date: 12 Jan 2007
Posts: 970
|
05-03-2009 07:21
I'm working a little more with my moving object script and have come up with a few issues. I thought I wrote it so that the object would return to its original coordinates--it just moves in a 5m square right now. Using a little snippet I found that makes it report its position each time it runs shows that it's not actually going back to exactly where it started: [5:18] Object: I'm at <175.00000, 20.00000, 522.00000> [5:18] Object: I'm at <175.06220, 20.00137, 521.99270> [5:18] Object: I'm at <175.01740, 20.03902, 521.98860> [5:19] Object: I'm at <174.98350, 19.96114, 521.97910> [5:19] Object: I'm at <174.98860, 19.94894, 521.97500> So I've spent the last week off and on trying to figure out how to make it move back to its original location on its last trip. That's resulted in the script below. (I was so pleased with myself when I defined that StartPos vector!  ) Now I'm getting a syntax error on line 37: "llLookAt (vector) StartPos;" When I comment that line out, the script compiles and runs ok, except that of course the prim doesn't rotate on the last trip and it still doesn't start again from its original StartPos coordinates  [7:18] Object whispers: I'm at <175.00000, 20.00000, 522.00000> [7:18] Object whispers: I'm at <174.99710, 21.15135, 521.99590> [7:18] Object whispers: I'm at <174.99390, 22.30253, 521.99180> [7:19] Object whispers: I'm at <174.99090, 23.45389, 521.98770> So many questions! Is SL just not capable of the sort of precision I'm trying to achieve? Is there a better way to get my object back to exactly where I want it? I know the errors seem pretty small, but I intend to allow this to keep running continuously and after a while the object would be too far from where I want it. Also, are all those llSleeps going to make the script laggy? Would I be better using timer events and having it read coordinates off a notecard (not that I entirely know how to do that at this point but would enjoy puzzling it out)? Thanks in advance for all the excellent help I know I'm going to get  vector StartPos;
default
{
touch_start(integer total_number) { StartPos = llGetPos(); llWhisper(0, "I'm at " + (string)llGetPos()); llSetStatus (1,1); llLookAt (<5.0,0.0,0.0> + (vector) llGetPos(),2,0.5); llMoveToTarget (<5.0,0.0,0.0> + (vector) llGetPos(),3); llSleep (3); llStopMoveToTarget(); llStopLookAt(); llLookAt (<0.0,5.0,0.0> + (vector) llGetPos(),2,0.5); llMoveToTarget (<0.0,5.0,0.0> + (vector) llGetPos(),3); llSleep (3); llStopMoveToTarget(); llStopLookAt(); llLookAt (<-5.0,0.0,0.0> + (vector) llGetPos(),2,0.5); llMoveToTarget (<-5.0,0.0,0.0> + (vector) llGetPos(),3); llSleep (3); llStopMoveToTarget(); llStopLookAt(); llLookAt ((vector) StartPos; llMoveToTarget ((vector) StartPos,3); llSleep (3); llStopMoveToTarget(); llStopLookAt(); llSetStatus (1,0); } }
_____________________
I've trademarked the apostrophe. You're in trouble but you are not. 
|
|
Trep Cosmo
Registered User
Join date: 3 Mar 2005
Posts: 101
|
05-03-2009 07:54
From: someone llLookAt ((vector) StartPos; Should be: From: someone llLookAt((vector)StartPos); You were missing a ')'.
_____________________
"There is no 'I' in team, but there is a 'Me' if you scramble it." -- House
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
05-03-2009 07:57
And since you have already defined StartPos as a vector, there is no need to declare it:
llLookAt (StartPos; llMoveToTarget (StartPos,3);
The same applies for:
(vector) llGetPos()
llGetPos() returns a vector and there is no need to define it as one.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
05-03-2009 08:07
And forgot that you need the other two variables in llLookAt(StartPos, 2, 0.5) So you end up with this: vector StartPos;
default { touch_start(integer total_number) { StartPos = llGetPos(); llWhisper(0, "I'm at " + (string) llGetPos()); llSetStatus(1, 1); llLookAt(<5.0, 0.0, 0.0 > +llGetPos(), 2, 0.5); llMoveToTarget(<5.0, 0.0, 0.0 > +llGetPos(), 3); llSleep(3); llStopMoveToTarget(); llStopLookAt(); llLookAt(<0.0, 5.0, 0.0 > + llGetPos(), 2, 0.5); llMoveToTarget(<0.0, 5.0, 0.0 > +llGetPos(), 3); llSleep(3); llStopMoveToTarget(); llStopLookAt(); llLookAt(<-5.0, 0.0, 0.0 > + llGetPos(), 2, 0.5); llMoveToTarget(<-5.0, 0.0, 0.0 > +llGetPos(), 3); llSleep(3); llStopMoveToTarget(); llStopLookAt(); llLookAt(StartPos, 2, 0.5); llMoveToTarget(StartPos, 3); llSleep(3); llStopMoveToTarget(); llStopLookAt(); llSetStatus(1, 0); } }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Bodhisatva Paperclip
Tip: Savor pie, bald chap
Join date: 12 Jan 2007
Posts: 970
|
05-03-2009 08:11
Taking out the "  vector)" worked for llMoveToTarget (StartPos,3); but I'm getting a "Function call mismatches type or number of arguments" for the "llLookAt (StartPos);" part, with the cursor positioned between the "s" and the "  " I don't know if where the cursor sticks is significant. I seem to recall reading somewhere that it's not a reliable way of knowing where the script is wrong. ETA: Oh! I'll bet that's it, the other two variables. Thanks to both of you. Now to see if the "drifting" issue persists.
_____________________
I've trademarked the apostrophe. You're in trouble but you are not. 
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
05-03-2009 08:50
From: Bodhisatva Paperclip Now to see if the "drifting" issue persists. The drifting is happening because calling llMoveToTarget with llSleep is not very accurate. You really would need to dump the llSleep and use at_target instead. This gets a little more complicated but you did make a great start. I will take a look at it some more later and someone else may jump in here to help.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Bodhisatva Paperclip
Tip: Savor pie, bald chap
Join date: 12 Jan 2007
Posts: 970
|
05-03-2009 10:09
Thanks, Jesse. I'll take a look at at_target this week and see what I can do.
_____________________
I've trademarked the apostrophe. You're in trouble but you are not. 
|
|
Bodhisatva Paperclip
Tip: Savor pie, bald chap
Join date: 12 Jan 2007
Posts: 970
|
Back at it!
05-22-2009 05:00
Does this count as a necropost?  I've been messing with this script off and on since I first posted and below is the current version. Along the way I tried having it change state when it arrived at its first destination but then was using touch_start to get it to go to its next one. Not practical for something I want to just move on its own. One version very similar to the one below actually made the object move to the new position and back. I don't know what I messed up, but now it's not moving back. Also, I would like it to move around to multiple destinations relative to llGetPos but I don't know how to feed it those in sequence. The other problems are that it just bumps along on the ground rather than staying up in the air like my original "sleepy" version and it's stopped looking at the target. It's been fun plugging away at this, but now it's time to admit I need help. Don't, of course, just give me the whole answer, but rather point me to some clues if you can. I learn much better that way and it's geekariffic fun! Thank you! vector StartPos; integer targetID;
default
{
touch_start(integer total_number) { StartPos = llGetPos(); vector destination = <5.0,0.0,0.0> + llGetPos(); float range = 0.3; targetID = llTarget( destination, range );
llSetStatus (1,1); llSetBuoyancy (1.0); llLookAt (StartPos + <5.0,0.0,0.0>,4,5.5); llMoveToTarget (<5.0,0.0,0.0> + llGetPos(),3); llStopLookAt(); } at_target(integer number, vector targetpos, vector ourpos) { llLookAt (llGetPos() + <-5.0,0.0,0.0>,4,5.5); llMoveToTarget (<-5.0,0.0,0.0> + llGetPos(),3); llStopLookAt(); llSetStatus (1,0); } }
_____________________
I've trademarked the apostrophe. You're in trouble but you are not. 
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-22-2009 06:59
if your list of places to go to (waypoints) is known in advance,, either as global points, or offsets from the last point, you can include them in a list with a counter. initial call... gPosTarget = llGetPos() + llList2Vector( gLstWaypoints, gIntCounter ); gIntTargetID = llTarget( gPosTarget, 0.1 );
in not_at_target apply your movement method to get to the target. in at_target use the following call to update_ llTargetRemove( gIntTargetID ); if (++gIntCounter < 5){ gPosTarget += llList2Vector( gLstWaypoints, gIntCounter ); gIntTargetID = llTarget( gPosTarget, 0.1 ); else{ llOwnerSay( "done" ); }
I prefigured 5 targets in that list, but you can use however many you need, and you can get them by counting the list length dynamically. if you want to loop through the list, then use ++Counter % List_Length in the target call, and skip the if statement. this version uses offsets from the last target, you may want to use region coordinates (use = instead of += in at target, omit the original llGetPos call). you may also want to start at a set point rather then be relative to where you are when starting, in which case you can either set the first point as region coordinates, or add a region coordinate instead of llGetPos.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-22-2009 09:08
Note that llMoveToTarget() IDEALLY will never actually reach its target point; it'll just get very close and then closer and closer as time goes on. If it is really a known route, I suggest keeping track of the point the object was SUPPOSED to be headed toward (the result of your last compulation) instead of the point where the object currently IS (llGetPos()). That's where a lot of people accumulate a "drifting" problem over time; it's not llMoveToTarget(), but their incorrect use of it.
|
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
05-22-2009 09:14
Good point, I normally use a target a little beyond the waypoint, too.
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
05-22-2009 19:26
From: Hewee Zetkin Note that llMoveToTarget() IDEALLY will never actually reach its target point; it'll just get very close and then closer and closer as time goes on. If it is really a known route, I suggest keeping track of the point the object was SUPPOSED to be headed toward (the result of your last compulation) instead of the point where the object currently IS (llGetPos()). That's where a lot of people accumulate a "drifting" problem over time; it's not llMoveToTarget(), but their incorrect use of it. heh i didn't mention that, but you'll notice my example was coded for it. the target variable is applied for the next offset, and not the current position which might be a bit off (I gave it .1m). glad you raised that, because habit just had me skipping right over it to the code I use.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Bodhisatva Paperclip
Tip: Savor pie, bald chap
Join date: 12 Jan 2007
Posts: 970
|
05-23-2009 06:44
Thanks, everyone! This should keep me busy for some time. 
_____________________
I've trademarked the apostrophe. You're in trouble but you are not. 
|