Using the func_tracktrain gives us some missalignment when using a long track so when you arrive at a level there will be a step from the elevators floor to the levels floor.
I found the following method in order to fix this problem. It also has the benefit that the whole system is very easy to set up and requires no further I/O if more than three floors are used.
Make your elevator. It doesnt matter what it looks like. Make sure to parent everything that should move with it.
-No Pitch (x-rot) unless you want that. Make sure your elevator is oriented towards 0 0 0 in that case (it will rotate correctly ingame)
-No User Control
-Is unblockable by player
Create two path_track entities and connect them to each other. Place the bottom one where the elevator has its origin point (blue marker) or move the origin point of the elevator itself.
Make sure to set the “First Stop Target” in the func_tracktrains properties to the bottom path_track (called path in this case).
Create a func_button. Give it a name (elevator_buttons in this case) and place it at the first level. Copy that button and make it parent to the elevator (same name).
Create an info_target** and place it at the exact same location as the bottom path_track is. Call it something like “target_level_1”
Create a logic_measure_movement and set it up as such:
“path1” is the upper path_track in this case
Lets start with the buttons. Select BOTH and give them the following Outputs.
Next up is the upper path_track (its called path1 for me)
Thats it for setting up the logic. Now its just copy/ pasting and renaming the info target to get more levels.
For example I made 4 levels but you can have say 100 levels and the logic wouldnt change.
To get a new level you will have to copy the buttons and create a new info_target where the elevators origin would be when it arrives at that level. Rename the target so it has the number on which floor it is on (target_level_2 etc).
Note that when adding a new floor a new button is made BOTH on the elevator and on the coresponding level.
The new buttons I/O looks as follows (buttons for level 3 eg):
really the only thing that changes is the parameter for the logic_measure_movement.
Tadaa youre done
The cool thing is this can be used to create moving objects that do not have a fixed target. As you can also set the measuretarget to for example the player you are pretty much able to create guided missiles etc.