Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.10
more ▼

asked Mar 08 '16 at 04:18 AM in C++ Programming

avatar image

9 8 16 17

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first


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!

more ▼

answered Mar 08 '16 at 07:53 PM

avatar image

232 16 8 25

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question