Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Train that Follows Tracks

Dioxide DeSantis
Registered User
Join date: 2 Feb 2007
Posts: 63
09-10-2007 10:27
Does anyone know how this could be done?

I am trying to build a subway car that follows a track but I am not even sure where to start?

I have tried simple car scripts but they dont stay on a track at all and I have even tried a hovercar script but I can not get it to stay on the tracks even if I use a prim it seems to not move at all.

I am also attempting to work with the Autobahn script but the setup is a bit more difficult.

Then I saw some model trains by Prim Worx and that looks like just the thing I am looking for. Does anyone know of an open source one that might work in this fashion?

Thanks
Diox
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
09-10-2007 12:34
I can't point you at any scripts, but maybe I can give you some ideas.

Each piece of track occasionally says "I am here at this position and rotation" on a private channel. The train listens for those, figures out which one is next, and then goes there.

Each piece of track could have a sequence number. The train could broadcast a "where is track number 49?" message, and track 49 could reply.

Static...lay your track. Manually record all of the positions on a Notecard. Put the notecard in the train. The train reads the notecard and then moves to those locations.

Cartoon train. Train decides where to go. Train temp-rezzes pieces of track right in front of itself, and then goes there.
Lilith Tiger
Registered User
Join date: 27 Nov 2005
Posts: 9
09-10-2007 14:27
Another way that may be simpler and cause less lag would be to have the train scan forward using llSensor looking for a particular named object which would be the track. If you get multiple hits which you probably would, just use the closest one, avoiding the one you are currently on by not doing another sensor scan till you are past its position, or just keep track of the key of the one you are on.

That way the track is completely passive and all the scripting is in the train.
Dioxide DeSantis
Registered User
Join date: 2 Feb 2007
Posts: 63
09-10-2007 17:18
From: Lilith Tiger
Another way that may be simpler and cause less lag would be to have the train scan forward using llSensor looking for a particular named object which would be the track. If you get multiple hits which you probably would, just use the closest one, avoiding the one you are currently on by not doing another sensor scan till you are past its position, or just keep track of the key of the one you are on.

That way the track is completely passive and all the scripting is in the train.



Yeah I am wondering if this is how they did it. There were no scripts in the tracks at all that I could see and they were just simple 1 prim nothing special tracks.

Only issue is I don't really know where to start to even make something like that.
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
09-11-2007 00:22
From: Dioxide DeSantis

Only issue is I don't really know where to start to even make something like that.


http://wiki.secondlife.com

that's where...
Triple Peccable
Registered User
Join date: 7 Jul 2007
Posts: 70
09-11-2007 01:09
Mr. Crookshank might be able to help. Go to the region named Crookshanks.
Cynthia Centaur
Registered User
Join date: 31 Oct 2006
Posts: 22
09-11-2007 01:37
I have thought about similar things for a while now.

What you need is:

1. Find a track. That can indeed be done by a sensor. Or by other means.
2. The surface, that you want to follow: Either talk to the track or let it chat, ......
3. The next track. Multiple ideas, not crucial.

But the most serious problem I still think about:
To make the movement smooth you can't simply hop from track prim to track prim. You need to "glide" along the tracks in a smooth movement.

To do that (either physical or non-physical) you need to know the next waypoint you want to go to. That needs you to understand and calculate the parameters of your track.
Simple for a straight track, possible for a curve.
Funny and challenging for most other "tortured" prims.
The bottom line is, you need to implement a *lot* of geometrical knowledge into the script.

Cynthia
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
09-11-2007 03:36
My steam train ride uses programmed waypoints in the train itself, read from notecard. Seems to be the fastest and least laggy way to go about it, considering the train engine and cars are physical to begin with.

The waypoints are generated using the train engine which has a "record" mode, then you dump out the waypoints from it and put them on the notecard.
Lilith Tiger
Registered User
Join date: 27 Nov 2005
Posts: 9
09-11-2007 08:41
From: Cynthia Centaur
I have thought about similar things for a while now.

But the most serious problem I still think about:
To make the movement smooth you can't simply hop from track prim to track prim. You need to "glide" along the tracks in a smooth movement.

To do that (either physical or non-physical) you need to know the next waypoint you want to go to. That needs you to understand and calculate the parameters of your track.
Simple for a straight track, possible for a curve.
Funny and challenging for most other "tortured" prims.
The bottom line is, you need to implement a *lot* of geometrical knowledge into the script.

Cynthia

Either physical or non-physical will work, although physical is smoother (but buggier).

In thinking about your second point, it seems to me that if you stuck to straight an circular curved track segments the calculation of the geometry wouldn't be very complex. The sensor could get you the position, rotation, and key of the object. If you are in the same sim, you can get the description which could encode the type of track and it's radius, arc, and relative center of curvature which would be used to drive the train motion.

I'd be tempted to put a script into the track which kept modifying the description when the track was being laid. Once down, the owner could use a dialog box in the script to have it finish the description information, then kill itself. If you needed to reshape the piece, just drop another copy of the script into it, just moving it wouldn't be a problem because the train would use the position and rotation to make the description's relative position absolute.

Anything more complex than lines and circle segments would be significantly more complex.

Since you can't get the description from an object in another sim, you could either just wait till you cross the boundary, never have a track break at a sim boundary, or do something complex like have a "pathfinder" object out in front scouting out what was in the next sim. I'd just never have a track end at a sim boundary. Crossing sims is a mess in any case.
Ray Musketeer
Registered User
Join date: 22 Oct 2005
Posts: 418
09-20-2007 14:30
If your still looking for the place to start it would be in wiki's scripting tutorials under making robotics or animating objects. Also, I have two different train scripts one I got for free here in the Script library another writen by a friend both use differet approaches . The sensor scanning for waypoints is best IMO. I also run a Kitto Flora train at my free public yard sale at Fhelzgud and its done the same, by waypoints. The sensor scans and the center points of the prim s they seek is what they find so an earlier poster was pretty much right on in their assesment:-). Hope this helps, Good Luck
Dioxide DeSantis
Registered User
Join date: 2 Feb 2007
Posts: 63
09-20-2007 16:11
From: Ray Musketeer
If your still looking for the place to start it would be in wiki's scripting tutorials under making robotics or animating objects. Also, I have two different train scripts one I got for free here in the Script library another writen by a friend both use differet approaches . The sensor scanning for waypoints is best IMO. I also run a Kitto Flora train at my free public yard sale at Fhelzgud and its done the same, by waypoints. The sensor scans and the center points of the prim s they seek is what they find so an earlier poster was pretty much right on in their assesment:-). Hope this helps, Good Luck



I think I have the free one that uses a notecard to place coordinates in but its not as smooth as I would like. Is the script your friend wrote work on the sensor scanning for waypoints system? That sounds just like what I would like to do.
Ray Musketeer
Registered User
Join date: 22 Oct 2005
Posts: 418
09-20-2007 18:03
Yes its written using way points and a lot of the code you might cut & paste from this resource http://rpgstats.com/wiki/index.php?title=TutorialRobotics.
Dytska Vieria
+/- .00004™
Join date: 13 Dec 2006
Posts: 768
09-20-2007 19:34
Highlight transparent around some linden tracks and you will see some scripted markers. I don't know what they do.

James Gill made trains that followed LL tracks... He was very nice and good.
_____________________
+/- 0.00004