Path_Track (and it’s sister entities, such as Path_Corner) is one of the simplest yet most versatile point entities in Source, and it’s one that many people never get a chance to fully try out, especially since it doesn’t seem very complex from the outside.
To put it simply, Path_Track lets you mark out paths that other entities can follow, whether they’re NPCs, moving objects or other invisible entities that the player never gets to see. It’s not the same thing as a navigation mesh, since it’s not telling NPCs where they can and can’t go – it’s just showing them a path that they’re supposed to follow when triggered in a certain way.
The biggest difference between a Path and a normal navigation mesh is that it tells a character when, where, and how to move, but not why. The chosen NPC (in this example, let’s say it’s a Combine Soldier) will be given a new goal of reaching the next point in the path chain, but it won’t have any context for why it should, unlike the natural movements to avoid grenades or flank the player. This makes it less of an AI tool, and more of a way to set up specific routes that you want something to take during gameplay.
A Path_Track is only one part of a chain, so a full path will take at least two to set up. Each one needs a unique name, and needs to have it’s Next Stop Target set to where the chosen entitles are supposed to go next. The end of the chain doesn’t need to lead anywhere, but you can also choose to have it loop back if you want to create a circuit that makes the entity move in a repeating pattern.
The unique name is important, and not just in terms of the path itself – each path in the math, regardless of what it’s connected to, needs a separate name that isn’t shared with any other entity. After all, a straight path can’t end in two places or split off into multiple directions.
If you do want a path that eventually splits off into other sub-paths or multiple ending points, you’ll either need to create more than one separate path, or set up triggers to change the Next Stop Target of the point that acts as your ‘junction’.
You should also keep in mind that paths and standard navigation AI often work together in an… unusual way. If an NPC bumps into an object in their way, they’ll try to shuffle around it, but they won’t walk around the object if it’s large enough. There are ways to mark a position that an NPC should navigate to on their own, but a path isn’t one of them, and you’ll need to specifically mark out the exact lines they’re supposed to take.
Creating A Path
Creating path points is easy. To start, put one down with the Entity Tool like with any other point entity. It’ll just be a little grey cube, the standard shape of a lot of entities without their own icons or graphics. On it’s own, a single Path_Track is nearly useless, but there’s an easy way to fix that.
First, double-click the entity and add something to it’s Name and Next Stop Target. I personally like to name it after the path’s purpose, such as “Combine_Path_01_P1“, but anything will do. The next stop target, ideally, should be related to the Name (in my case, I’d use “Combine_Path_01_P2), but this is just to make it easier to manage multiple paths at once.
When you’re ready to make another one, select it in one of the 2D views and hold down the Shift key, then drag it somewhere else. This’ll create another path, with a line going between the two. What’s happening here is that the engine is automatically filling out the new Path_Track’s properties to create a connection between them, which is what the yellow line signifies. You can keep doing this if you want – as long as you do it in a linear way, you can automatically create an entire path without having to adjust the settings yourself.
You don’t need to use this shift-drag method, though. In fact, I often do it manually, since it makes it much harder to slip up and create a broken or split path. Every Path_Track entity you create can be altered to change it’s connections, so you can have two separate paths meet at a single ending point, or have multiple NPC movement patterns end up in the same loop.
Like a lot of point entities, Path_Tracks have special properties that you can use to alter how they work. The most notable is an Flag labelled “Teleport to THIS path track” which lets you make an attached entity teleport to that marker whenever they’d normally move to it. This is great for things like trains, production lines or background characters, since it helps create an illusion of there being more to explore that the player can’t reach without forcing you to build an entire looping environment or tunnel.
You might also notice an option for a “Branch Path” in the Class Info page. This is used to create an alternate path, which you can trigger just like any other entity action. The Flag option “Branch Reverse” also lets you mark this alternate path as a way to travel backwards, rather than forwards.
One of the most useful options you can change is the Oreintation Type. If you’ve made something like an elevator or a moving platform that follows a path, you won’t usually want to use the default setting – this’ll make it swing around to face that way it’s travelling, which often results in players getting flung off the side or instantly killed after being crushed against a wall.
The Flags mentioning an “uphill/downhill path” are mainly used in Team Fortress 2, as a marker of how the payload cart should move on slopes. They don’t often apply to other games, but feel free to use them anyway if you want to.
Path_Corner is almost identical to Path_Track in every way, with only a handful of differences that make it better suited to specific roles. For a start, it has a value that you can use to make entities wait before continuing on. You can also adjust how fast objects turn – there’s no option to stop them from turning, like with Path_Tracks, which is why they’re mostly useful for corners (as the name suggests).
Both entities are interchangeable, and you can link them together. You can even use the same shift-drag method to create multiple corners at once, and you don’t even necessarily have to use them as corner nodes at all. However, if you’re actually using them for corners, it’s a good idea to stagger them and use multiple for a smoother transition between angles.
Getting Something To Follow Your Path
Once you’ve gotten a path ready, how do you get something to follow it? Well, it depends on the entity, but most compatible entities will have their own “Next Stop Target” field. Simply put one of the path nodes’ names into there, and that entity/NPC/whatever will start to follow it from the note you’ve entered. If it loops around, they’ll follow that loop indefinitely, otherwise they’ll stop at the end of the path. Player-controlled vehicles like Func_Tracktrain can be driven backwards down these paths, etc, but without additional scripting or triggers, most entities will either stop (if they’re brushes or inanimate objects) or resume their normal behaviour (if they’re NPCs).