How do you do map triggers

So I want to do a trigger, say when PLAYER(model) gets to a certian point, then something happens, capture a flag/spawn monsters/open gate. My train of thought would be to either setup an invisible box, that can be collided with and then the trigger gets set off. If you know the Hammer Map tool for Source SDK, it is the idea of setting up a brush with a trigger setting. Or would it be better to do it based on coordinates. When PLAYER(model) is 100<x<125; 150<y<175; 200<z<225, then the trigger goes off. Or are there other options that I am not thinking of. What do you think?


The trigger (entity) system was originally introduced in the quake engine based games, and subsequently into Valve’s games. The quake engine called a trace of the player’s bounding box of every physics frame and each collision that the trace detected was checked against all trigger entities in the map. The appropriate touch method was called for each entity detected.

You could implement a system as described above using ray’s… but if you’re using bullet physics in your game, you might as well take advantage of the collision results provided by that at this time. So go with the first idea you mentioned above. This being said, you’re going to have to come up with a way to include the trigger entities into your map/scene externally from the model you create for your level.

I’ve actually been mulling over this same issue for a few weeks now, and I’m actually kinda working on a compiler for .map files produced by radiant/Hammer based level editors that will include support for these types of entities.


I would certainly avoid using hardcoded coordinates, that doesn’t make your solution easily repeatable… I would create a class that has “interactive points” the point would describe the location and the action to take if the player reaches that location. Keep all these points in their own data structure. and loop through them every update() to determine if the player is with a certain distance of that interactive point (you could get the location of the player, and the interactive point, draw a line, and get the line length, if line length is within the threshold, perform the specified action…

Just a thought this would probably involve extending a Node for the interactive points which the tutorials frown upon, i personally like doing it because i’m more familiar with it then using controls… but that’s probably just my lazyiness

Ghostnodes are the way i go. I check the collisions and trigger “onTouch”, “onTouchStart” and “onTouchEnd” in my python scripts. Works fine for me and dosnt eat too much if used wisely. If there is no “onTouch” but “onTouchStart” and “onTouchEnd”, the “onTouch” is called but eats nearly no resources, since i check some things and stuff.

I guess its a fine way to do things.


I even attach those Ghostnodes to spatials and give em interaction that way and stuff.

Thanks for the replies.

Yeah it would be nice to have trigger entities, let us know how the .map implementation goes Feen sounds awesome.

I didn’t want to do the coordinates way but I figured I could break up the map into sections to do it, and then just load all of the coordinates up in a data structure and do what you said run through it every update.

I will have to look more into the GhostNode, that seems like a really good method of doing this.