x

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"

Problem with multiple weapons

I'm having a really weird issue. I have things setup using 2 weapon inventory slots, WeaponEquipped (The held weapon) and WeaponSecondary (One on your back). I have no problems with collecting the weapons and having them fill the correct slots and all is good.

The problems begin when I try to start with a weapon in the Equipped slot. When I spawn the weapon, set it to fill the WeaponEquipped variable and attach it to the socket, it shows up properly. When I pick up a new weapon though, it is no longer sending it to the WeaponSecondary back slot and is adding it to the one in my hand. Here is the node layout for my weapon spawning, which is being handled inside by Character BP:alt text

And I end up with a situation like this:alt text

The weird thing is, if I remove the SpawnActor node and simply do a cast to the Machinegun_BP and keep everything from the Set WeaponEquipped onward, everything works properly but I don't actually have an equipped weapon ingame, just logic that tells the game that the variable is populated.

My pickup, variable assignment and socket attachment logic is as follows:alt textalt text

The first part, the Collect Function, resides inside my Character BP.

The second part, the Overlap Event, is inside my Weapon BP.

For some reason I just can't get this to work. Any ideas?

Product Version: UE 4.10
Tags:
weaponspawn.jpg (131.8 kB)
ingame.jpg (9.3 kB)
weaponbp.jpg (160.8 kB)
collect.jpg (104.7 kB)
more ▼

asked Jun 05 '16 at 10:01 AM in Blueprint Scripting

avatar image

SithHunter
95 8 10 12

avatar image SithHunter Jun 05 '16 at 10:28 AM

Ok, so I solved the stacking issue. I had completely forgotten to destroy the actor before setting a new WeaponEquipped in my Collect Function.

The problem now is that it will always replace my spawned weapon before setting the picked up weapon as the WeaponSecondary. So basically it's still not seeing the weapon I'm spawning with as being a valid WeaponEquipped and is proceeding to overwrite that first before populating the second weapon slot.

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

1 answer: sort voted first

Hey there Sith,

Let's take a look at the blueprint node "? is valid" in the Collect function, change that over to the blueprint node of "Is Valid" (where "Is Valid" has the green "f" in front of it, not the ?). They both take a object reference, and let's see, if that fixes, by detecting that the passed object doesn't actually exist.

If it still fails in the same fashion, insert one more check after the new Is Valid blueprint node, and that is to get the display name for the object, and check that the length of the returned string is greater than zero. I know I wrote my own "Is Valid" blueprint node, in order to take care of some anomalies with the standard library.

Jay

IceWare Inc.

IwSpline

more ▼

answered Jun 05 '16 at 10:30 AM

avatar image

jayice
1.4k 41 28 56

avatar image SithHunter Jun 05 '16 at 10:45 AM

Hi Jay,

Thanks for the response. So I changed over the node to use the function but it's still doing the same thing. When I got the display name of the WeaponSecondary variable and told it to print, it gave me the name of the spawned BP that I had assigned to the WeaponEquipped slot on BeginPlay.

It's not ideal, but what I've done is then manually set the WeaponSecondary variable to NULL after the weapon has been spawned and attached and that seems to be a workaround for the time being. Not sure why that variable is being auto-populated though.

(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