How to? Trains

Naso

L2: Junior Member
Jun 11, 2009
84
9
Hey guys, I'm trying to get just a simple train to work on my map, one that goes in a straight line and respawns back were It started, with a trigger hurt to It will kill people.

I'm having a lot of trouble with It, I have looked for a lot of information on how to do It but I just can't get It to work.

Any info on how to this something like this working would be awesome, thanks.
 

Ezekel

L11: Posh Member
Dec 16, 2008
818
245
i'm writing this from memory, as i don't have hammer available at the mo to check it, and i'm too lazy to look up a tutorial on it, so some of this might not be exactly right.

your train is a brush entity (i think track_train is the name, make sure it's "track" and not "tank").
if you want to use a model (like a train engine like in cp_well), you create a prop_dynamic, set it's model to what you want, and parent it to your track_train brush.
if you'r eusing a model with your train, you probably don't want the brush to be visible in game then, so set it's render mode to "don't render", and texture it as nodraw (don't use playerclip, or clip ... otherwise people and sentry guns will be able to shoot through the train)

where it will go is determined by point entities called "path_track"
so plop down' 2 path_tracks. give them names like "track1" "track2" or something. and set them up so that A: they point to the other one for the next path_track field and that B: they use "fixed orientation" for the direction the train should face.
on "track1" set the flag "teleport to THIS path_track" to be checked.

now on your track_train, set the 1st path_track to be "track1"

if you want it to kill things, you create a brush and turn it into a trigger_hurt. i can't remember the damage type you need to use to make it display the train icon when people are killed by it.
next make sure that the trigger hurt is in front of the train, and parent it to the train.
now what you want to do is make sure that the trigger hurt hurts everything (except debris) - that's a flag that you check. this means it will kill sentrys/dispensers/teleporters that get in the way of the trains movement.
next create a filter_name entity and set it value to = the name you gave to any train props you parented to your train, and make the trigger hurt use this filter. this stops the trigger hurt from trying to apply damage to the train models.


note: trains normally must be built facing to the right in the top down view. however as your's is moving in a straight line, you can build it to face the direction you want it to go in, and set it's orientation type to "fixed orientation" (it's a flag i believe).

note2: parenting means that something will stay the same distance and orientation from what you parent it too. so you still have to make sure that parented things are positioned in the right place relative to the track_train, otherwise, they'll move in a straightline like you want, but won't be in the position that you want.


hope that helps
 

Naso

L2: Junior Member
Jun 11, 2009
84
9
Awesome, thanks for the explanation, I was looking through the well map for train stuff so this makes sense, but they go into a lot of logic stuff and it got confusing.

I'll report on how I did later, thanks again.
 

Naso

L2: Junior Member
Jun 11, 2009
84
9
Awesome everything seems to be working good!

Now I have to figure out how to make it start going at random times not just constantly running.

The only problem is that the trigger hurt only works when the player gets pushed into a wall for some reason?

Any ideas?

Here Is the vmf If you want too look at It, If there's any mistakes or something.

https://files.getdropbox.com/u/1334246/train.vmf
 
Last edited:

maxtraxv2

L3: Member
Jan 23, 2009
103
3
works fine for me, but you can get stuck inside of the model witch then you wont die

but thats becuase its so fast
 

lucky

¯\_(ツ)_/¯
May 25, 2009
583
145
Is its parent the func_tracktrain?
Does it start disabled (should not)
Does it have an associated name filter, which filters OUT that which your train is called?
How much damage is it set to?
Is the damage type FREEZE?
Is the damage model normal?
Is the Zero Damage Force set to NO?

Does the trigger_hurt actually cover the train so players hit the trigger before the model?
 

Naso

L2: Junior Member
Jun 11, 2009
84
9
It's parented to the train, Prop_dynamic.
Start disabled is set to, No
Yes it does ( Name: train_filter, Filter Name: train model ( Prop_dynamic name. )
The damage is set too 2000
Yes the damage type is freeze.
Yes the damage mode is set to normal.
Yes the Zero Damage Force is set to no.

Yeah It covers all of the front part of the train model.

Changed the parent and tested it out, and tried lowering the speed, and still nothing, I can walk in front of the train and glide off with out taking any damage.
 
Last edited:

lucky

¯\_(ツ)_/¯
May 25, 2009
583
145
try

filter_activator_name

name: train filter
filter mode: disallow entities that match the criteria
filter name: train*

func_tracktrain
name: train1
damage on crush: 1000
maxspeed(if it makes a difference): 1024

prop_dynamic
name: train1_model



I think just making sure both the model and trigger are parented to the func_tracktrain should do it, but we'll see.
 

Naso

L2: Junior Member
Jun 11, 2009
84
9
Sigh thanks for the help, I have changed everything to what you have specified but the player can still slide right off the train while hes getting pushed by it. Ill try some random things with the brush positions to see if it will work.
 

lucky

¯\_(ツ)_/¯
May 25, 2009
583
145
If all else fails, copypaste the one from Well :p

Just make sure you set the start velocity to something, and go into the outputs and delete them all.
Don't forget to copypaste the filter!


You may need to do Alt+P to fix the hammerID problem (to get rid of it)
 

Naso

L2: Junior Member
Jun 11, 2009
84
9
Yeah I was looking at the train from well, It's very complicated. It has so many logic stuff that ties to other stuff, It's too advanced for me.

Thanks for trying :)

If i ever do get it to work or anyone elce have any ideas, ill post here again. !
 

lucky

¯\_(ツ)_/¯
May 25, 2009
583
145
Oh I am silly.. I forgot about the flags for the trigger_hurt.
(I always forget about the flags)

Flags ticked: clients, physics objects, everything (not including physics debris), physis debris



(The copypasting would remove all ties to the logics, just copy the trigger, func_tracktrain and model and it's good to go.. just need to change the path track and the initial speed.

The logics on the train are for telling it to start and stop. The track has ones for when the train passes to tell the gates to open and the sound to go choooo choooo and the warning lights and sounds to come on)
 
Last edited:

lucky

¯\_(ツ)_/¯
May 25, 2009
583
145
Okay I just downloaded your map and your filter is set to ALLOW. It should be DISALLOW. I changed it, ran it and it kills you. (But not it's not moving. whut.)

SUCCESS. Yeah I just fixed that parenting you had wrong in that map and it works fine now.
 
Last edited:

Naso

L2: Junior Member
Jun 11, 2009
84
9
Yeah that was the older one, before you told me to change it.

I just re downloaded it and tried changing it, still doesn't kill you on contact only kills you when you reach the end of the level and get crushed.
 

lucky

¯\_(ツ)_/¯
May 25, 2009
583
145
What :c

All I changed was the parents, the flags (you pretty much had everything ticked rather than the 4 things) and switched a few names around for my own sake.
 

Naso

L2: Junior Member
Jun 11, 2009
84
9
So I figured out why the trigger hurt was not killing you on contact, it was the flags, the "Only" flags were confusing the game i guess, next time i wont select almost everything lol, thanks alecom.

But now, what would i need to look up to learn how to make the train stop and go at random intervals, not continuously running?