Falling headcrab tutorial

Browsing the model animations of the npc_headcrab, you may have spotted the falling animation ceiling_fall and landing animation ceiling_land and asked yourself why headcrabs hanging from the ceiling has elegant falling animations while headcrabs otherwise don't.
The purpose of this tutorial is to primarily use a scripted sequence to simulate a scripted fall that looks better. (Note that this is designed to be a scripted fall specific to a headcrab falling a certain distance to a certain destination, but you could probably make it general enough to encompass general NPCs, through the use of filters, through providing landing zones at each fall point, and through tying fallspeed controllers to any falling NPC.)
=== Basic setup ===
We will start by setting up an npc_headcrab on top of a simple platform, which we will trigger to break to that the headcrab falls down. This means we will make the platform a func_breakable. (For aestetics, you can set the Material Type keyvalue of the platform to match the material it is made of.) Name the platform "Crab platform".
Next we set up a trigger_once trigger to trigger the platforms with the simple output:
To get a good look of how an ordinary headcrab fall looks, we can compile and run the map now. (You can use a Block LOS tool texture if you want to prevent the headcrab from jumping off the platform from seeing you.)
=== Falling animation ===
Now it's time to add the scripted sequence, but first, every actor has to have a name, so name the npc_headcrab "Headcrab".
Now create the scripted_sequence anywhere in the map, and change the following keyvalues:
Link it to the trigger_once like so:
If we compile, we'll see that the headcrab assumes the falling position and falls, but there's two problems: First of all it falls way too slow, and second or all it will not "land" once it reaches the floor.
=== Landing ===
We will fix the landing first, by creating a thin trigger_once at the landing zone, and giving it the following output:
(We won't need another sequence to play the landing animation because the falling animation will automatically play it while transitioning to the normal idle animation.)
We will also need to set the flag of the trigger to apply to the headcrab instead of the player client (which is default):
(If there are other NPCs involved in this area, we would need to create a filter_activator_name to make the trigger specific to the headcrab named "Headcrab", to prevent the other NPCs from triggering this trigger prematurely.)
=== Falling speed ===
Now it's time to speed up the falling speed of the headcrab. We do this by parenting it to a moving entity, and letting it "carry" the headcrab downwards. We could parent it to a func_tracktrain that would travel to a path_track, but when it's only a matter of a single destination, we can use the simpler brush entity func_movelinear instead. (This entity is actually a door, that when opened is meant to "slide" a certain distance, but as long as it's invisible, nobody will notice.)
Create a func_movelinear with the following keyvalues:
We also need to set its Not Solid flag:
We also need to parent the controller to the npc_headcrab:
Then we need to trigger it in the first trigger_once:
Finally, we need to detach the headcrab from the controller once it has landed (so that it can move freely) so we add the following line to the landing zone trigger_once:
== See also ==
* scripted_sequence
Category:Tutorials