Can you set more than 2 weapons in ShooterGame?

Planning on making an FPS with ShooterGame as the basis. But I’d like to know one thing… can you set up more than two weapons? I’d like to have a DOOM style weapon system in which you can carry every weapon at once.


Two choices, first: If you want to start with all the weapons, the code automatically spawns for them for you if your weapon is a subclass of AShooterWeapon and adds them to your inventory. For this to happen, you also need to add your custom weapon into the player pawn blueprint (forgot the actual name, in the folder Blueprints/Pawns in the editor). You can find existing blueprints for weapons in the blueprints/weapons folder, and by duplicating those and adding your own meshes to the duplicates and changing the gun attributes, you can easily add weapons. The difference between the two classes (Instant and projectile, from these the WeapGun and WeapLauncher are derived from) is that the gun shoots and calculates hit within an instant and the projectile weapon shoots a slower projectile that is an actual bullet flying through the air.

You don’t need to go to C++ unless you want to add some special attributes, if my memory serves me right, doing a shotgun needs a bit of tweaking at the C++ side, because the instant weapon can not shoot multiple projectiles at a single time.

So to recap for automatically starting with certain weapons: Duplicate either WeapGun blueprint or WeapLauncher blueprint and edit it to your liking. Go to the character pawn blueprint, search for inventory, add new weapons/change the existing to the inventory that spawns.

Second: If you want to add weapons to your inventory during the game, there is a function called AShooterCharacter::AddWeapon, and as you can see it, it’s under AShooterCharacter.cpp. This function is not accessible through blueprints, but can easily be made so by editing the ShooterCharacter.h → add the line

UFunction(BlueprintCallable, BlueprintPure)

above the declaration of the AddWeapon function. There are also other functions in AShooterCharacter that are related to your inventory that you probably find interesting, so check that class out and make an awesome game!