Download

How to cast to pawn

so ugh im trying to make a pokemon styled game or atleast get a template for it and i have 2 pawns… that are just circles with difent materials… now how do i cast it ? im trying to get the variables from these pawns to show in the health bar but it doesnt because because the bars arent red

I’m assuming that you’re trying the bind the health bar progress to the pawns. A better approach would be to send the health values from your pawn to the HUD widget, every time the health changes. This way your widget does not have to know about what pawn its related to. It just needs to know how to update the health bar provided the required values.

Plus it’s a lot more efficient than binding since you’re calling health bar updates only when one of the pawns is either damaged or healed.

The literal answer to the question: Get ahold of the appropriate AActor, and then use Cast To Pawn, in some blueprint function.
Interestingly, the AActor class itself has a concept of damage, but it can’t be read out as a value, there are only interfaces to affect it: Damage in UE4 - Unreal Engine

Unreal generates Cast To Xxxx for any class that is correctly compiled and is of a matching class for when you add a “cast to …” blueprint node: