Mounted guns

Not every Source game can partake in the awesomeness of or, but using other entities you can still make a mounted gun, and get more customization.

This tutorial is based off one by TopHATTwaffle:, so original credit goes to him.

Following the mouse
First, make your gun and its base. These can use whatever entities you want. For the gun, this tutorial uses a called.

Make an on the spot you want the gun to pivot around. We'll call it.

Next we need a so we can tell when the player is trying to use the gun (by grabbing it). The button should ideally be non-solid, but still "push-able", so texture it with  (if you don't have it, you'll have to settle for   which is solid to players). We'll call this. Parent this button to the gun and set the Don't move flag. For, you have to make some changes: (See here)

Next make a, which will track the player's crosshair. Name it, and we'll come back to it later.

Next make a and name it. This will make the gun follow the player's vision. Set the settings to these:

You might be confused how this part works right now - don't worry, we'll get there.

Go back to your  and add these outputs:

Now go to the  and add these outputs:

Shooting
Make an, parent it to the gun and put it on the front. Name it, set Start Disabled to Yes, parent it to  , and set everything else however you like.

Since the bullets don't actually do damage, we have to emulate it with the next best thing: a. Shape this trigger so that extends out from the gun as much as your map requires it to. Drag the trigger's origin (little white/blue circle) to the far end of the trigger.

Go back to your  and set Target to.

Now add these inputs to the :

Depending on the game, you might be missing a firing sound. If so, make an, name it , set the Is NOT Looped flag and give it a gunfire sound.

Make a with these settings:

Finally, add two more outputs to the :

TF2: alternative button
Since TF2 doesn't let players use things with, we'll let them grab it in the next best way: hitting it. Make a, name it  and set Weapon Slot to Melee. In your, check the Damage Activates flag and set Damage Filter to. You'll also have to change the button's texture to  and live with it being solid. Don't change any outputs!

Env_gunfire doesn't appear in Hammer
This entity is missing from most FGDs, but it is usable. Some Source games will have a halflife2.fgd which does have the entity. To add that fgd, go to Tools, Options, Add, and select. If your game didn't come with one, copy the  code from here and paste it into an FGD Hammer is using.

Bullets don't fire
This happens in most games because they're missing some things from Half-Life 2. On the, set Tracer to Default.

Players have a hard time grabbing the gun
It's probably because the gun is getting in the way of the button. Make the  bigger.