Problems with Set members in struct

Hey all,

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).

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.

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).

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 :slight_smile:

I’m using UE4 4.9.2

Thanks in advance.

That is because you change the value from a copy of your struct.
Print out the ammo amount after the Set Member function to see what i mean.

One way to make this work is to put the select node with all your struct in there,
change the struct pin with your amo typ enum and set that up and if im not wrong it should work.

Thanks, it works perfectly! Can’t believe it was so simple. I have provided a screenshot incase anyone else has the same issue.