Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Auto pilot, monorail..whatever!

Starbuckk Serapis
Registered User
Join date: 10 Nov 2006
Posts: 114
03-01-2008 15:35
I've been scouring the wikis, forums, web and in world for some kind of starting point for creating a physical movement script for something like a train or ship or whatever and have had no luck. I've tried various combinations of the llLookAt, llMoveToTarget and various others and just not getting things to work.

SOmething that would simply move a monorail to three different points would be enough to get me started. Nothing fancy...unless this is in itself constitutes "fancy", lol. Seems like it should be simple..but I'm missing a connection somewhere and without a basic sample, have no idea where to look.

TIA for any help!

EDIT: TO clarify, i'm not referring to a mousefly type script. I mean AUTOMATIC movement between multiple points while avatars are seated on the object.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
03-01-2008 15:46
I just used look at and
llSetPos( llGetPos() + <0.x, 0.0, 0.0> );
in a loop untill I get to my check point (or within range of it)....
_____________________
|
| . "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...
| -
Farallon Greyskin
Cranky Seal
Join date: 22 Jan 2006
Posts: 491
03-01-2008 21:46
I made a boat on my sims that travels a very complicated path around them.

I basically made 'bouy" that I set out to form a point to point path. The bouys when touched would give me (llOwnerSay) the global coordinates for the position of the bouy. I cut and pasted them all into the script and then deleted all the bouys.

My vehicle then starts out by rotating itself to face point 1, then moves forward. When it gets within a couple meters of it it then rotates to face point 2 and so on. A timer checks the boats position every couple of seconds to see if it needs to switch to the next waypoint.

Works really well on the boat except when it tries to cross sims and SL makes it go haywire randomly :(

I also had to put in code so that if it got stuck somewhere it would self delete. Also put code at the lunch point such that if the boat was way LATE (because it deleted itself) then the launch would rez a new boat and send it on it's way.

For a monorail, I've seen systems that are set to follow a track using some other mechanism. I'm not sure my method would work as well for a monorail as my boad tends to wander a little :) in the water it's rine, on tracks it might look bad.
Sho Iuga
Registered User
Join date: 6 Jun 2007
Posts: 35
03-02-2008 15:10
one of the tricks with decent physical movement (unless you want to use a vehicle) is to use llMoveToTarget and restart it while it still damps into the target. Something like that:


vector targetpos = <7,55,44>;
float speed = 5.0;
llSetStatus(STATUS_PHYSICS,TRUE);
while( llVecDist(llGetPos(), targetpos) > 0.2 )
{
vector movedirection = llVecNorm(targetpos- llGetPos());
llMoveToTarget(llGetPos() + speed * movedirection, 0.4)
llSleep(0.1);
}


this will restart the damping before the damping starts to become slow and thus move the object smoothly to targetpos ( within 0.2 meters ... make sure speed isnt too fast or you get undesired effects ).
I dont know if this helps you, but for me that was a mayor discovery when I tried to get my little cable car in tyranus to work.

Side note:
Instead of the llSleep trick you could use a timer event
Atashi Toshihiko
Frequently Befuddled
Join date: 7 Dec 2006
Posts: 1,423
03-02-2008 18:33
I have a few ferry boats on my sims that travel back and forth between destinations. I use the vehicle functions to make a normally functioning boat, and use the linear motor to handle the propulsion. To handle the steering though I use llRotLookAt, to turn the boats towards their destination. When the boat is rotated within +/- 5 degrees of the target, the motor starts up. They run on a timer loop to continually adjust their course and monitor their position, when they are in the correct region and within a few meters of their destination, they use nonphys movement (setpos / setrot) to 'dock'.

To build a monorail, I'd start with a freebie land vehicle script, remove the 'control' stuff and replace that with your preprogrammed destinations / waypoints. Also, have a look at the existing SL rail roads -- they use a neat invisible guide-rail to keep the train vehicles on the tracks. For a monorail, that guiderail wouldn't be invisible of course, but I think it's a clever idea to keep the train from wandering off course. In fact, you could pretty much forget about steering entirely, just worry about propulsion, and position.

-Atashi
_____________________
Visit Atashi's Art and Oddities Store and the Waikiti Motor Works at beautiful Waikiti.