This article relates to the game "Half-Life: Alyx". Click here for more information.
This article relates to the workshop tools for "Half-Life: Alyx". Click here for more information.
This article's documentation is for Source 2. Click here for more information.

Trigger Player Out Of Ammo

From Valve Developer Community
Jump to: navigation, search

Introduction

This tutorial will teach you how detect if the player is out of ammo or out of a specific ammo.

Setup

Create a test room. Insert a trigger_player_out_of_ammo mesh entity. In its properties, select the Ammo Type: All, Energy Gun (Pistol), Shotgun or Rapidfire (SMG).

In the outputs, add the following output:

My Output Target Entity Target Input Parameter Delay
OnPlayerOutOfAmmo <targetEntity> <input> 0.00

Finishing up

Compile and run your map, and you should have a trigger that, whenever the player enters it or is inside it without the selected ammo, it will output OnPlayerOutOfAmmo.

Beware, if you remove the ammo from your backpack and there is nothing left there and in your trigger, it will fire the output.