Editing Variables in a Strucutre
I guess a simple Question, i hate to store 2 much Variables on the Character Blueprint, so variables i dont need to change inside the character bp, i just store in an Structure. Like for this example, it works with the healthregen and ratio. While health/Maxhealth are stored in the Character BP.
Im workin rn on a talent tree, where the player can use points to gain a higher health regeneration.
Neither :
"Set var by ref" or just connecting a local var in the widget to the "Make P_Stats" pin does work.
Is there anything im missing? Set var by ref should work, but it doesnt.
Posted May 2, 2019, 6:25 AM UTC
24
Use "Set Members", like that: https://imgur.com/a/L0UuDpv
Other than that, in order to keep your functionality compartmentalized instead of cluttering the character class, I'd recommend going a step further and create dedicated components, such as one for character health, one for inventory, one for quest management, another for the talent tree, etc. You can use Actor Components, Scene Components, Child Actor Components (which can have components of their own) or UObjects.
Your Pawn Actor should serve as a hub for all such modules and have as little own logic as possible. This way the code is organized much more conveniently by keeping your classes focused on a single responsibility and in many cases, reusable (you could plug the health module into an AI controlled unit for example).
Ah finally an answer, and good one too, thank you very much
One question to the pictute if im allowed to ask, did u make the structure reference by promoting it to an var or just using 'make structure' and hiding all pins?
Ah i see that makes way more sense, i love it when things are organized, really appreciate it
I made a sample struct asset and created a variable of that type in an actor. Then Ctrl+dragged that variable into the event graph.
Isn't that a bit impatient?
Well i guess i am an impatient person, i dont really know what to answer now
anyway thank you, you really helped me a lot