|
Bartiloux Desmoulins
Think Kink? Think Bart!
Join date: 27 Sep 2005
Posts: 121
|
12-05-2006 13:08
Not yet having been able to get my mind around the concepts involved with physical motion in SL, my scripts thus far have been "cheating" a bit to obtained the desired results. For instance, if I want an object to move between two points, I usually start with the current rez locale as the starting point, and the ending point is some X, Y, or Z offset from there. I've been using For/Next loops and llSetPos commands to make it looks as though an object is moving towards a target when, in fact, it is simply moving to various intermediate steps along a straight path in somewhat rapid succession. This has been working well for me but I was wondering something. Instead of having the endpoint be some predefined offset from the starting point, I would like to be able to move my av to the ending point, after having rezzed the object, and then use a llListen to "tell" my object that the place where I am presently standing is to be recorded as the ending point. How can I, within the object's script accomplish this? What I need to end up with is a vector that I can compare to (or subtract from) the vector of the starting point so that I can move my object along that path like I have been doing before, with a predefined ending point. Any suggestions in simple layman's terms that you might have would be GREATLY appreciated. Bartiloux p.s. In case my narrative above isnt' quite clear, envision the object being a dog and you standing some place and saying "Come here" and the dog walking a straight line to you WITHOUT the use of any tricky math related to physical objects.
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
12-05-2006 14:31
Well, assuming you were in chat range of the dog (and not shout range), you'd be in sensor range. So the dog could find your position by running a sensor scan for you. Psuedocode: listen handler: if (message == "come here") llSensor(for owner)
sensor: destinationVector = llDetectedPos(0); originVector = llgetPos();
... the rest should be what you're doing now
And if you use physics, llMoveToTarget should produce smooth damped movement to the destination. I'd say the math for non-physical movement is trickier  With physics, you do have to mess with buoyancy, potentially.
|
|
Bartiloux Desmoulins
Think Kink? Think Bart!
Join date: 27 Sep 2005
Posts: 121
|
12-05-2006 17:21
Wow! That sure looks easy enough. Thank you. Something you said in your reply, made me thing of yet another scenario / question. What IF you ARE beyond the normal chat range? Will shout work for listens and for sensors? If not, what other mechanism would you recommened of accomplishing what I'm trying to do?
Thank you, again, for your reply! Bartiloux
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
12-05-2006 17:31
Shout works up to 100m. I'd recommend setting up a listener on a non-0 channel for that, because you probably don't want half the sim to hear you calling your dog.
Sensors work up to 96m. So you could be in shout range and outside sensor range.
If you're trying to move the object that far, watch out for crossing sim borders. For one, sensors don't work too well across sims. And more importantly, you could end up moving to the wrong place. For instance, if your detected position is 10,10,0 but one sim over, then the object probably needs to try to get to 266,10,0 (or whatever), i.e. you might need to add/subtract 255 to the detected position, depending on the direction in which you're trying to cross the sim boundary.
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
12-06-2006 03:37
You could use a command that triggers a local script to shout for the dog giving it your sim position in globalcoordinates using llGetRegionCorner ?
|