Getting Object Reference?

Im new to UE4 and still learning how things work. I made widget blueprint to show player’s health percentage. Im using int PlayerHealth from another blueprint. UE4 says i need object reference from another blueprint.

Does anyone know how to get object reference?

im assuming that the player health variable is on the character that the player will be controlling. if thats the case then all you need to do is use a get player character node, then plug that into a cast to (insert the name of your character bp here).

basically what you need is a reference to a specific actor that exists. so this could be an actor that is placed in your level at build time, or a actor thats spawned in later, it just needs to exist and it needs to be a specific instance. so lets say you have two thirdpersoncharacters in your level the object reference you would need would be a reference to a specific one of the two. to get a reference you could use things like public variables or traces. or if you need to get the player character you can do as i mentioned earlier and use the get player character and a cast. the get player character gets a reference to the character the player currently posses and the cast identifies it.

im not really sure how you got all those nodes to show up without having the correct object.

hi,

follow my graph.

The reason to reference is that since your variable is been created inside another BP, you should provide the reference information for the engine. This way engine will know where to look for that variable.

Although my setup is not the best setup for such purpose, it will do the job for you. Note that this setup only works if the variable is created inside your third person character BP. If not, then you should provide the engine with the proper reference.

Cast to node is a one to one communication tool inside unreal. It allows you to access to functions and variables of a specific BP from another BP.

Regards,