Download

Casting to Character Blueprint Class Child

Hi, When casting to a character blueprint class child that is used as an AI, what is the object reference to cast to. Seems to like player pawn, but no idea what the pawn id would be for each, rejects AI Controller.

Attempting to cast from a hud widget to get the max/current health.

Hi BlenderCube

(I appreciate the name lol)

Is this widget created by the player or is is a widget component of BPC_AI Boar Class? The answer will depend on this.

Generally though, when casting you need to get a reference to that actor that is in the game world. Typically this is done through the hit result of a line trace or collision volume overlap. Once you have an actor reference, you’ll be able to cast to the specific class you’re looking for.

At the moment I have the calculation for what the HUD display health should be based on a tick in the UI constantly asking the NPC blueprint what its current and max health is and dividing them, this will probably change to a trigger on taking damage after I have the system working due to the cost of tick.

I might move this calculation over to the NPC blueprint if that’s a better thing to do for cost or simply organisation. At the moment I have no real identifier for the enemy to take damage other than a custom damage volume, but I want this to eventually be caused by either directly being hit by a weapon, or by being the active target of an ability/spell.

I have attached another image of what I might end up doing instead (putting the calculation in the character blueprint and then casting to the UI), then any overlap events will be easier to connect up as its inside the same system. There will be instances of the NPC blueprint with their own health bars.

Thanks.