Transmitting variables to my Character Sheet

I’m having a lot of trouble getting my Character Sheet to display the variables of my Third Person Character. Upon initialization of the character, stats are calculated, that part works and displays the correct stats. When a weapon is picked up, stats are calculated again, that works fine and dandy as I can get a string to print with the correct Attack Power calculation. However upon trying to call these stats in my UMG Widget Character Sheet, it will only display the unadjusted character stats without any weapon considerations. The weapon becomes a Null reference as soon as the widget is constructed. Here is how the blueprints are set up.

http://puu.sh/lyCyV/7f7bfb73c2.jpg

http://puu.sh/lyCDI/0908320f1c.png

http://puu.sh/lyCGO/d864519e1a.png

Not sure if this is the problem, or not, but in the final screenshot you’re grabbing an array of all of the weapons, then adding an invalid weapon onto that list at index ‘Item ID’. Surely you should be using ‘Get’ instead?

Also, I’m not entirely sure what you’re trying to achieve, but I don’t think that’s going to work. There’s no guarantee that that getting all weapons will return the same list each time, so your index may be invalid/incorrect.

I just realized i should probably be using Get Instead! Thanks, ill let you know if it works!

Still no luck. I’m getting the same error when I try to bring up my character sheet. If it helps im trying to make a character sheet that displays the stats of my character in an RPG.

How are you identifying the weapon that you’ve just picked up? As I mentioned in the previous post, if you’re getting all weapons in the game, you may get a different list entirely each time.

If this were me, what I would do is:

  1. On your character, store a list of the current stats of the character. (The best way to do that so you don’t have to keep passing dozens of ints around is to build a struct and just pass that around).
  2. When you pick up a weapon, store a reference to the weapon on the character. Afterwards, now that your character has changed gear, you can re-run ‘calculate stats’ once (using any equipped weapons/gear to adjust the stat values) and just update the stored stats (as seen in step 1)
  3. Whenever you want to show the stats, just pass the entire struct to the class that needs it and let it read them off.

Thanks, structs seem to be the answer here!

Hi Triblade,
i have the similar things like your description i want to achieve,
lets say i have actor that i randomly spawn into the level, i have connected BP structure to the default class of the actor (name, health, traits, etc.).

I need the information to be passed to UMG to be shown there (imagine if i click michael jordan, i can see his name, speed, strength, photo), but i was not be able to find how retrieve the data and pass it to UMG in blueprint.

Do you have any information about it ?

It depends a lot on your setup, but I can give you a very high level example of what you’re suggesting and hopefully that’ll get you on the correct path:

Presuming you’ve already got the UMG object (Let’s call it MyPanel) spawned somewhere (i.e. MyPanel is always present on the screen but only shows the currently selected actor’s details when an actor is selected), when you select the actor, you could call a function on the MyPanel (let’s call it “UpdateDetails”) that takes in your struct as an input parameter.

You’ll need to be able to access to MyPanel from somewhere (so you either need to have access to the actor that spawned it or use ‘GetAllWidgetsOfClass’ to find all of the spawned versions of it) and then call the ‘UpdateDetails’ function from the actor that was just selected.

Inside ‘UpdateDetails’ you’ll simply be able to break the struct and pass the individual pieces of information to the relevant UI elements.

Hope that helps.

hi thanks for the response,

the large goal is to pass the data to umg
but the issue now is how to get information inside the default class structure out by selecting the respective actor

i’m using on input touch/click event on the actor with hope that unreal knows which actor i selected and i can retrieve the data, but that node outputting primitive component reference, with get owner i can get actor component, but no way to set/pass the data to the structure.

Ok, presuming that the static meshes’s owner is a valid actor containing the data required, drag the pin from the ‘return value’ of the ‘Get Owner’ node and type “Cast” into the search. See if the actor class you’re using is in that list and, if so, cast to it. Then you should be able to drag off of the cast and find the data.

If you’re then spawning the UMG widget here (as pictured), do so, then on the ‘return value’ of the "Create HUD char… " node, either call the function to set the data or pass it the struct - whichever works better for you.

It worked with a bit of tweak following my setup, thanks for helping Triblade and Ridingkeys for hijacking your thread.
Cheers