Entities in Depth

== Introduction ==
Entities provide the level of interaction found in all levels, from the car that explodes to the Antlion Guard throwing you across the room it all originates with entities. Entities provide all the interaction a level designer can create and also provide a lot of functionality. Entities are essential to level design, period.
=== What they are ===
An entity is a collection of special information that informs the game how to behave and how particular objects behave. All the information that defines what entities can do is hidden away within the game's code; therefore, for Hammer to know and use the possibilities that exist, a reference file is written. The reference file is know as an FGD, and is important to note because it lists all the information about entities, as far as Hammer is concerned. The FGD does not create the entities, it just tells Hammer how to use the code. Level designers work with two types of entities, point and brush. Each categorizes a different set of properties and effects which are then created and used in different manners; however, they both work exactly the same.
:Point Entities: A point entity is usually the first type of entity you will come across. It has no physical size it merely occupies an infinitely small point in space (occasionally, the point itself does not even matter). Point entities are used to position an effect or model (env_sprite, prop_static), or to keep track of information (math_counter, logic_branch). Point entities are placed via the entity tool.
:Brush Entities: Brush entities differ from point entities in the fact that they occupy physical spaces, brushes are taken and then turned into a brush entity. As brush entities occupy physical space they can block the player (func_door), or monitor an area (trigger_multiple). As they rely on brushes, they aren't created with the entity tool (select any brush and press Ctrl+T or the "toEntity" button in the lower right).
Further information on using entities can be found here. An entity consists of several different groups of information: Properties, Flags, and I/O. All go together to make one entity and often work in conjunction (for example, inputs can change properties, flags can alter a properties effect, and properties can define what triggers an output). The three groups of information are detailed below.
=== Properties ===
Properties are the variables of an entity, they can contain any value or a set range of values. The properties detail information such as name, color, or rendering effects. There is a property and a key value. The key value stores the information about the property, whether the Color property is blue, red or green. Hammer will put detailed names and descriptions of the effects up on the screen with the feature "Smart Edit", turning it off removes the user friendly names and help and reveals the properties and values as seen in game.
=== Flags ===
Flags represent simple boolean conditions of an entity. They often change the fundamental behavior of an entity. Often overlooked, useful conditions are often found in here such as "Motion disable" for a prop_physics to stop it moving at all. Flags often set default states or dis/allow a certain behavior. Flags themselves cannot be changed in game, but sometimes the properties they affect can be.
=== Inputs and outputs ===
Inputs and outputs are how information is passed between entities. Inputs and outputs are directly linked to each other: when an output condition is met, it is triggered and that information is then passed into an input. That input will then cause certain changes within the receiving entity. 
When a player walks into a trigger_once, the OnStartTouch output is fired. This can then trigger any input on another entity making a light go on or an alarm sound.
Simple at first glance, the I/O system is incredibly powerful and can even go so far as reproducing simple games such as breakout. Looking at an entity's available inputs can tell you what you can change, but often a bit of experimentation is need to figure out when each output is fired.
=== Using entities ===
Proper use of entities is one of the topics that goes far beyond the scope of any one article, but as a simple introduction to entities here’s a few of the common tasks explained in depth in their own tutorials.
* Simple button controlled door tutorial - Door creation
* Intermediate physic light tutorial - Hanging lamps
* Intermediate car explosion tutorial - Car Explosions
* Advanced tutorial on controlling Antlions - Antlions: Random Spawn
There are a lot of examples to be found in the <e-mail>/sourcesdk_content/... folder that demonstrate how to use several of the simpler and even more complex entities and plenty more tutorials on the site; however, your own ingenuity and understanding are the true keys to unlocking their power.
== Conclusion ==
Entities are the core of interesting level design and allow great flexibility and power, time should be spent familiarizing yourself with them and their effects. Often creating small maps for the single purpose of playing with an entity’s effects is a great way to spend some time, as understanding what entities can and can't do can save hours of grief when trying to implement effects in full blown levels.
Category:Level Design