Working on the Railroad: the bge and paths

I’ve often been curious as to how to do something in blender… or whether it could be done in the first place. I’m using as my model one of my all-time favorite video games: Uncharted 2.
Aside from the high detail and smooth controls, I’m curious as to a specific part. In one of the game’s most memorable scenes, the main character boards a moving train. The train continually runs along a track, while new, pre-constructed track/landscape segments spawn randomly in front of it.
I’ve done my own (fairly unsuccessful) tests involving this process, using a track to nearest script as the means to force a train to track to independant path nodes. I think I have an idea as to how to do this successfully, but I’m curious as to whether there are more efficient means to present this.
No urgency on this, just curious. Any information will help.

For your path nodes, you might want to use a property and a bit of python to pull this off.

So you start generating the path nodes, when they are first generated, the property ‘node’ would be an integer set at 0, there would also be a property called ‘search’ which would be a string, and an init property which makes sure the list is only run through once.

Then in a python script you would have something like this run at the object’s creation which loops through the list of objects (which stops execution when the end of the list is reaches), NOTE: untested


import GameLogic

con = GameLogic.getCurrentController()
own = con.owner

scene = GameLogic.getCurrentScene()
objList = scene.objects
length = len(objList)

if own['init'] == 1:
    for x in range(0, length):
        own['search'] = objList[x]
        if 'node' in own['search']:
            #not sure how to set the value of another object here in this case, see at the bottom of this post#
        if x == length:
            own['init'] = 2

Then you would have another script which would set the object that the track-to actuator tracks to the object that currently has the highest value for the ‘node’ property, the idea would be that through the first script, the older nodes will have higher values as new nodes are created.

On the comment, I’m not sure how to go about doing that, but I think this may provide a clue
http://www.tutorialsforblender3d.com/GameModule/ClassCListValue_7.html

Hey, I posted on your other thread.

Sorry for yet another communication delay of mine.
Thanks for the response on the other thread, SolarLune. The computer is working fine, but the internet has to be re-established, and my user re-created. When I can arrange for another user to be created, I’ll look into the file, and restart the thread.