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"

best way to equipp/switch weapons?

Hello, so I am currently working on a FPS game and I (currently) have 14 primary weapons and lots of attachments.

What I currently have:

When I selcet a weapon the selected weapon is attached to the right hand of my character, the same is true for the secondary weapon and the pistol. Default the secondary and the pistol are not visible and can't shoot. When I press "2" the secondary weapon is set visible and the other two guns are invisible, when presssing "1" "3" similar things happen...So the weapon switching is based on visibility.

The problem:

It worked quit well, but now I am trying to add attachments to my weapons. They are only set visible inside the BP. when a player has selected them, however this causes some problems when switching weapons, as you can imagin...As there are about 30 different attachments that can be equipped(laser,scope,barrle,stock,mag...) to every weapon, setting the visibility with branches and variables seems a bit too much work. Also destroying and spawning a new gun when switching weapons is not an option, because the ammo details would get lost :/

my idea:

I would like to set the visibility of the weapon and the selected attachments to visible on spawning and then when pressing 1/2/3 on the keyboard not changing visibility, but instead socets. So when spawning my visible primary would be in my hand, the secondary on my back and the pistol close to my hip.

Do you have better ideas or maybe know how to do this? Thank you very much in advance! (i know the screenshot provided is not very good...)alt text

Product Version: UE 4.20
scree2.jpg (530.1 kB)
more ▼

asked Feb 16 '19 at 10:04 AM in Using UE4

avatar image

10 1 4

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

1 answer: sort voted first

So what is the issue? Seems like a perfectly good solution to me haha Use the "attach to socket" node and when you hit 1,2,3 switch the weapons that are located at the particular sockets. All your weapons, and attachments should be visible at all times. Unless you don't want the weapon to be visible that is not active for performance reasons then I suggest having its data stored in an inventory or a simple variable within your player character that will keep track of the weapon/s you are carrying. Each weapon BP should be responsible for keeping track of the attachments/ammo it has as well. I wouldn't mess with visibility in general it is not necessary. As for the issue about losing "ammo" data for why you can't spawn and destroy weapons, it is a simple fix. You store the weapon data before destroying the weapon. Variables are your friend. Then when you respawn the weapon, provide it with the appropriate ammo count based on the stored variable.

more ▼

answered Feb 16 '19 at 01:44 PM

avatar image

Nebula Games Inc
5.4k 28 9 15

avatar image Max2066 Feb 16 '19 at 11:18 PM

I am not quite sure how to switch the weapons. Is attach to socket enought? Does this mean it will just change location or will the root just transform in location, but the actual mesh not?

(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