Garry's Mod
Garry's Mod

Spawning and Controlling NPCs

Spawn and direct NPCs in Garry's Mod, from Combine soldiers to custom characters. Create dynamic scenarios and populate your sandbox world with AI.

Spawning and Controlling NPCs

Non-Player Characters (NPCs) are a fundamental part of Garry's Mod, adding life, challenge, and interactivity to the sandbox. From the iconic Combine soldiers and zombies from Half-Life 2 to custom-created characters, NPCs can be spawned and controlled to populate your worlds, create combat scenarios, or even act out complex narratives.

The primary method for spawning NPCs in Garry's Mod is through the spawn menu. Within the 'NPCs' tab, you'll find a wide variety of characters available by default, often sourced from Half-Life 2 and other Source Engine games. Simply select the NPC you want and click in the world to spawn it.

Spawning NPCs:

  • Spawn Menu: Navigate to the 'NPCs' tab in the spawn menu.
  • Categories: NPCs are usually categorized by their origin game (e.g., Half-Life 2, Counter-Strike: Source).
  • Selection: Click on the desired NPC to select it.
  • Placement: Left-click in the game world to spawn the NPC at that location.

Controlling NPCs:

Once spawned, NPCs can be controlled in several ways:

  1. AI Behavior: By default, most NPCs will follow their programmed AI. This means they will react to players, attack enemies, and navigate the environment autonomously.
  2. The Tool Gun: The Tool Gun is invaluable for NPC control. You can use it to:
    • Freeze/Unfreeze: Prevent NPCs from moving or acting.
    • Set Target: Force an NPC to attack a specific entity or player.
    • Change Team: Alter an NPC's allegiance, making them friendly or hostile to certain groups.
    • Teleport: Move NPCs to different locations.
  3. NPC Commander: Some gamemodes or addons provide an 'NPC Commander' tool that allows for more advanced squad-based control, directing multiple NPCs simultaneously.
  4. Lua Scripting: For advanced users, NPCs can be controlled and manipulated through Lua scripting, allowing for custom AI behaviors, unique actions, and integration into complex contraptions.

Popular NPC Addons:

The Steam Workshop offers a vast array of custom NPCs, ranging from popular characters like CJ from Grand Theft Auto to unique creations. Addons like VJ Base provide a framework for creating and controlling highly customized NPCs with advanced AI and behaviors. These can sificantly expand the possibilities for creating dynamic scenarios and interactive worlds.

When spawning large numbers of NPCs, be mindful of server performance. Too many active AI entities can lead to lag. Using the 'Freeze' option on NPCs you aren't actively controlling can help mitigate this.