I have multiple objects of a blueprint called solder , and each has its own value for a variable named health, I want to be able to access this variable in my HUD to show it on screen , What is the simplest way to make my HUD B access the health variable lets say for solder 2 ?
ok , from what i read , is that i can create a variable inside my HUD blueprint with class type of soldier and then reference its value to the required soldier and then i can get the health parameter , what i don’t understand is , why is it that i can instead of declaring it a class type of soldier i can declare it as an object of soldier !! so my new variable is an object of soldier but its not related to any of actual soldier instances in the game!!? even when i made it public variable i couldn’t set it to one of the created soldier instances , i can only do that with class variable, any explanations ?
Class is something that does not really exist in your game, it’s a prototype, a template. An object is an instance of that class. By declaring a variable you are just reserving space for that object (you are reserving memory, kind of). You still need to populate that variable with actual data - by spawning an object from a class or by setting its value in some other way.
The bottom line is, you are doing it right. Declare a variable in your HUD that can store that object (or just its health), store your value there.
Not sure what the problem is here - are you certain that both your soldier and your variable are of the same type? A screenshot could help.