Can't make "Set members in struct" node work

I am trying to increase one element of a structure with the “Set Structure Members” node but it is not working, or at least it is not working as i intended.!

If i am not mistaken this should get str, add new parameter on to it and set str as the new result right ?

I try to run it to see if it works but the result is :


Then i try with the normal “set struct” node

And what do you think happens next ?


Am I doing something wrong or the “set member” node works differently ? Any help is appreciated , i want to replace this abomination with the structure if possible :
[Too many variables][6]

*Sorry for bad formating, cant get it to space out as i see it in preview.
edit2: Think i fixed the preview, hope you can help me with the problem.

You asking for this ? I am trying to get all that stat stuff in a function library. its just a cast and a get


Seems like it worked but i didn’t really understand why


seems like it casts

The issue here will most likely be with how the Player Info is returned from that function. I feel you’re Setting Members of a copy of that struct. Blueprints copy a lot of data.

Could you tell a bit more about how that function works? Especially about how that pin ends up there.

But then again, you’d see it print correctly, even though it’s just a copy. If the default value of Strength is 0, then I’m right.

Every time you X GePlayer 1 returns a copy of the struct, you modify the copy’s default 0, print it. Rinse & repeat.

Also, are we sure the cast does not fail here? Can you put a print node there?

Yup, thanks. Above, the round pin icon is a copy of the data. A diamond (like on the Set Members) is a reference.

Could you test it by Setting Members inside this function and then return the result. It should work fine.

Your logic is absolutely sound. It’s the way blueprints handle structs and copy data all the time; it’s a frustrating experience, especially when one starts nesting structs inside other structs.

In, short: functions will not return structs by reference. They will create a copy of the data. If you then make changes to that data, you’ve made changes to the copy, not the original struct you intended.

When you change the data inside this function, you have, indeed, modified the original player’s data. Outside the function, you modify the data the return pin copied - that data is not the player’s data anymore.

One way to handle what you originally envisioned, is to push the data back in. The function returns the Player Reference (actors, luckily, are always by-ref), so after modifying the copy, set the player’s struct again. Since you’ve exposed only a single struct element, the rest will remain unchanged and behave.

This should work ok. Passing the player reference instead would also work, ofc.

1 Like

Here, if you pull the struct from the Player Cast and then Set Members in it, it should work fine.

I think that’s it.

This one is perfect. Thank you for your help !!