Jump to content
You are about to reply to a thread that has been inactive for 125 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Dear people,

Who can point me in the right direction when it comes to scripting train wagons? I've been trying to create a multiple prim wagon and make it follow the locomotive. The problem is that as soon as I link the wagon to the locomotive, it becomes one object, meaning that the wagon and its child prims follow the locomotive as if it is one piece.

Only the base of the wagon is following the rails, everything linked to that wagon is following the locomotive. Is it possible to make child prims follow a specific link number? (e.g. the wagon base is link number 2).

 

I found a script to make a complete wagon follow another wagon without actually linking them, but when I cross a sim border, the wagon gets returned to me.

Edited by RosemaryLively
Link to post
Share on other sites

As long as your train stays within the region, you can use a sensor in a follower script in each car to follow the car in front of it. As you have discovered, cars using this approach can't follow each other across region boundaries. Better than a repeating sensor, then, run a timer that checks for 

vector CarPos = (vector)llList2String(llGetObjectDetails(UUID_of_car,[OBJECT_POS]),0);

assuming that you grab UUID_of_car early on in the script, so that the script knows which car to follow.  If you use this second approach, you won't have to worry about what happens at region boundaries, since llGetObjectDetails will return information about an object in an adjacent region.  Something like this should work (not tested in world):

key UUID_of_Car;

default
{
    state_entry()
    {
        llSensor ("Thing 1","",ACTIVE|PASSIVE,10.0,PI);
    }
    
    sensor(integer num)
    {
        UUID_of_car = llDetectedKey(0);
        llSetTimerEvent(0.5);
    }

    timer()
    {
        list temp =   llGetObjectDetails(UUID_of_car,[OBJECT_POS, OBJECT_ROT]);     
        vector CarPos = (vector)llList2String(temp,0);
        rotation CarRot = (rotation)llList2String(temp,1);
        llSetPos(CarPos + <-0.7,0.0,0.0>*CarRot);
        llSetRot(CarRot);
    }
}

So, you set a script like this in every car, telling it to follow the one in front of it.  Then you reset all the scripts at once so that they each grab the UUID_of_car for the car in front of them.  When the engine at the head of the train starts moving, the others should follow.  I hope.

EDIT:  No, that's not quite right.  The rotations will all end up matching, which isn't what you want.  It's close, though ....

Edited by Rolig Loon
Ooops. Typo
Link to post
Share on other sites
  • 4 weeks later...

There is a version of the standard VRC train script which allows this, but it depends on the SLRR track system to keep the follower vehicles on the track. It does allow sim crossing, but there can be failures. It works on the SLRR but not on the new Bellisaria line, because of differences in parcel permissions. The follower vehicles have to be set to maintain their distance from the "driver" of the locomotive. This "Carriage" modification is by Kadai Flanagan, and the copy I have is No Transfer. I know you can get it in stuff from the Waxen Works range, and Kadai Flanagan is still active in SL

I am groping for an articulated vehicle version of this, a single linkset that can bend in the middle, but I need to understand how the Guide prim on the track is detected and followed. The documentation for the SLRR is woefully inadequate, a huge gap between knowing there is a Guide prim and the erratic commenting in the code. 

 

Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 125 days.

Please take a moment to consider if this thread is worth bumping.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...