Entities and Triggers
Shape the interactive elements of your Garry's Mod maps by mastering entities and triggers. This section delves into how these components function, allowing you to create dynamic environments, interactive puzzles, and responsive gameplay mechanics.
Entities are the fundamental building blocks of any Garry's Mod map beyond static geometry. They encompass everything from props and NPCs to lights and sound emitters. Triggers, a specific type of entity, are crucial for creating interactive elements. They detect when a player or other entity enters a desated area, allowing you to initiate actions such as playing sounds, spawning props, moving objects, or changing game states. Understanding how to place, configure, and link entities and triggers is vital for map des and creating engaging gameplay.
Common Entity Types:
- Props: Movable objects that can be static or dynamic.
- NPCs: Non-player characters with varying AI behaviors.
- Lights: Illuminate the map, with various types like point lights and spotlights.
- Sound Emitters: Play ambient sounds or specific sound effects.
- Info Entities: Mark spawn points, objectives, or other gameplay-related locations.
Key Trigger Functions:
- `OnStartTouch`: Fires when an entity enters the trigger's volume.
- `OnEndTouch`: Fires when an entity leaves the trigger's volume.
- `OnTrigger`: Fires when a specific condition is met (e.g., player presses a button).
- Linking Entities: Use the Entity I/O system to connect triggers to other entities, defining what actions occur.
Map editors like Hammer (for Source engine games) are typically used to place and configure these entities. However, many entities can also be spawned and manipulated directly within Garry's Mod using the Spawnmenu and the Toolgun. Experimenting with different entity combinations and trigger conditions will unlock a world of interactive possibilities for your maps.
| Entity Type | Function | Example Use |
|---|---|---|
| Prop | Movable or static object. | Furniture, crates, vehicles. |
| Trigger | Detects entity presence in an area. | Opening doors, playing sounds, activating events. |
| Light_Spot | Creates a directional light source. | Stage lighting, spotlights. |
| Info_Player_Start | Defines player spawn points. | Essential for multiplayer maps. |