[Tutorial] The Train

Discussion in 'Tutorials & Resources' started by flux, Jul 30, 2009.

  1. flux

    flux L1: Registered

    Positive Ratings:
    Alright, I've mucked around with the train a bit a couple nights ago and did get it working, though I did not play around with any of the logic timers and skybox train and the lights. I'll soon study cp_Well more in depth when I finish DEV'n out my map for alpha.

    This tutorial is help you understand basic of the train, if you've done a playload then path_tracks should come to relative ease

    So we are going to start off with the basic layout for the train, with textures. Just to get a simple look at where your train will be.

    Figure #1

    Alright sense we have the layout down we can get our path_tracks ready. So I set an entity at the left end of the map and make that entity path_track.

    Now we will name that path_track to something easy and nice to remember, but it's your choice to name what you feel.

    Figure #2

    Now get another entity and make that a prop_dynamic and get a model you would like as the train because your going to have to align the path_track center with the model you choose, because of this that train is going to follow that path and if it's high then when you go to compile your train will be suspended in the air...I know the future isn't that far away but making this act like a train is the key, also name your Train something easy also, you'll figure out why in a moment.

    Figure #3 I choose the Well train for this Tutorial

    Once you have that centered from where you want that, now we will use a short cut, Valve has made it easy for use this. Hold shift and click and drag your next path where you would like it to be placed. I just put my at the end of the map and kept it straight. (Like said, if you are familiar with path_tracks this should come to ease)

    Figure #4 The paths

    After that is all done and make sure the paths are connected if not you can go to first path and just make the Next Stop Target the name of your second path and you should get them connected like figure #4.

    Now create a nodraw texture and make it around the back of the train, try to get it even with the train with the sides don't make that nodraw really wide. Just look at my figure below:

    Figure #5 NoDraw

    now hit crtl+t to bring the options up, we will make the nodraw texture and func_tracktrain. Doing this will help move the train with the tracks. now click the train model and parent it with the func_tracktrain.

    These are the options with the func_tracktrain and I'll help you out with most of them, because I haven't figured all of them out entirely.

    Things we'll worry about for the train are:
    1. NAME (Name your brush! I named mine train_train :laugh:)THIS IS IMPORTANT YOU NAME THIS BRUSH
    2.FIRST STOP TARGET ( The first path that you had made, make sure that is the selection made)
    3.MAX SPEED & INITIAL SPEED (Play around with these, making it obvious but lower the number slower it goes)

    These are the basics to get the train working, I've only worked with the sound and velocity and height, but I encourage you to experiment with this stuff, I haven't gotten the time to do it properly.

    Now tie the Brush to the model by just holding ctrl + click to select both then ctrl + t to tie them together, make sure you push yes when the window pops up, if you push no then a new entity will be created loosing your func_tracktrain

    Now you have that all set, when you do compile your map it should move. If not there must be some things you missed, or my horrible teaching skills.

    But what happens if you want it to loop from back and forth from paths?
    All you have to do is go to your second path made and click Next Stop Path and link it back to your first. It should go back and forth, giving you a good idea on how the train works.

    But I want it to go in a circle!
    more path_tracks will do the trick, and remember to hold the shift and drag them because that will automatically link them, instead of having to do the manually. Then when you get around to your first path don't shift and drag again, double click on that last path_track and set Next Stop target to the first path_track, creating a loop. :cool1:

    But how do I get the train to hurt me when I run in front of it?

    What we'll do is did what we did with the nodraw but use a trigger texture and put the trigger in front of the train and tie it to the train.
    Also in the trigger_hurt's option in damage type use the FREEZE to get that train in the HUD.

    Also look here for trigger_hurt options:
    [ame="http://forums.tf2maps.net/showthread.php?t=6832"][INFO] Trigger_hurt damage types and effects - TF2Maps.net Forums[/ame]

    Now this is my first tutorial and might...wait I know for a fact it has flaws but I'm open to questions, and i'll try answering them, I didn't know much about the train before and I got the concept it seems. Hopefully I can get the Well stuff figured out soon:thumbup:
    • Thanks Thanks x 13
    Last edited: Aug 16, 2009
  2. The Political Gamer

    aa The Political Gamer

    Positive Ratings:
    How no one picked up on this tutorial is beyond me.
    • Thanks Thanks x 2
  3. Micnax

    aa Micnax Back from the dead (again)

    Positive Ratings:
    Should be trigger_hurt

    And yes, I'm surprised no-one did this, I've been needing it for a long time :D
    • Thanks Thanks x 1
  4. martijntje

    martijntje L8: Fancy Shmancy Member

    Positive Ratings:
    thanks I will be using this in my map (a racing-track themed map), wich wil have moving cars
    • Thanks Thanks x 1
  5. Nutomic

    Nutomic L11: Posh Member

    Positive Ratings:
    Maybe it would be a good idea to explain all this complicated stuff in well with the train, like the lights that flash before the train comes, the logic Entities that let the train appear randomly and that stuff, and maybe also the skybox train driving at the whole time, because this is really difficult.

    Nice tut, but you can do a lot more here :thumbup1:
    • Thanks Thanks x 1
  6. flux

    flux L1: Registered

    Positive Ratings:
    Oh I would love to get more! Just complicated with trying to figure what does what...I think I should add a train within my map I'm making now so I can get this done.

    hmm...spelling errors... :blush:
  7. SPHinx

    SPHinx L2: Junior Member

    Positive Ratings:
    Thanks to flux for this. I was able to add a train to my map-in-progress by reading through your steps. Much appreciated.

    However, I ran into a couple of snags, so I thought I would post them here in case others have similar issues.

    1. Not so much a snag, but a helpful, even if obvious, point to add here is that a logic_timer entity can be used to trigger the train's movement at regular or random intervals. I set my func_tracktrain's initial speed to 0 and then have the logic_timer entity set the speed to 2000 when it expires. This is done through a simple output of the timer, sending a parameter override value to the func_tracktrain's speed.

    2. You can also use this timer to change some lights, play some sounds, etc. Simply put a delay of so many seconds into the func_tracktrain output, and then add additional outputs to the logic_timer to turn on named light entities or sounds. (Note: I have actually not played with sounds yet, so I am guessing it works the same. I have got the lights to work though). In this way, you can have warning lights flash, say 10 seconds before the train shows up to run everyone over. To re-set the lights, you can then use an "Onpass" output of one of your path_tracks (like the last one) to switch everything back.

    3. Finally, when trying to set up a loop, whereby the train runs its course and then re-sets to run it again later (e.g., each time the timer expires), I initially had checked the "Teleport to THIS path track" flag on the starting path_track, so that when the train reached the final path_track, it's next destination was the starting path_track and it would just teleport there immediately. Unfortunately, when the train would teleport this way, it's "instant" movement was actually visible and the model could be seen to fly back down the path to the beginning. To fix this, I had the final path_track reduce the func_tracktrain's speed to 0 and then used its output---"Onpass" (set to fire after a few seconds)--- to teleport the train back to the beginning. Now the train stops and after a few seconds, teleports back to its beginning path without any visible trace of movement.

    [Correction: At times, I can still see a frame or 2 of the train teleporting back to its original location. Anyone know how to fix this?]

    I should perhaps add that there are likely other and better ways to accomplish these things. I am definitely a klugey map maker. But these tricks worked for me. =)
    Last edited: Sep 1, 2009