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"

Problems with Set members in struct

Hey all,

I've posted this question in the forums aswell.

I'm having problems setting the values in a struct, within a function. This is the first time I've really worked with them so I'm probably missing something obvious.

I have a base character class, with an "ActorComponent" attached to it called player inventory, which will store the players ammo for certain types of weapons. I also have a base weapon class with a reload function. Below are some pictures hopefully they can clear up what I'm trying to achieve better than I am able to explain it.

This function inside the inventory component that is attached to the character works, and returns the value I set (Here its set to 0, but it's set to 100 on the instance attached to the player).

alt text

This function inside the weapon blueprint works out the reload amount, I had it working when I had a single integer variable for ammo. Each weapon has an Enum called AmmoType.

alt text

And this is the set function, that isn't working, even after reloading, the players ammo stays at what it was set by default (100).

alt text

If I change from a struct to a simple integer, then it works and I am able to set it, but I want to use the struct if possible for flexibility with ammo types.

I hope I explained this well enough, if not just ask and I'll try to clarify anything

I'm using UE4 4.9.2

Thanks in advance.

Product Version: UE 4.9
Tags:
1.png (129.9 kB)
3.png (121.9 kB)
2.png (88.2 kB)
more ▼

asked May 19 '16 at 03:20 AM in Blueprint Scripting

avatar image

Job4aCowboy
6 1 2 4

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

1 answer: sort voted first

This question has been answered on the forums. I'll provide the solution incase anyone else has the same issue.

The problem was I was setting a copy of the struct, rather than the actual struct.

alt text

Credit to "Urm92" for the solution

4.png (105.3 kB)
more ▼

answered May 19 '16 at 02:13 PM

avatar image

Job4aCowboy
6 1 2 4

avatar image 6r0m Mar 01 '19 at 08:55 AM

in my case I enabled check mark "pass-by-reference" in the function input for copying disable

(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