Variables from an inherited class ACharacter

Hi,

I’ve got a problem with the values being returned for a super class.
I’ve got the following classes:

  1. CharacterBase → inherits from ACharacter
  2. HeroCharacter → inherits from CharacterBase.
  3. EnemyCharacter → inherits from CharacterBase.

I’ve got a variable bDied in the CharacterBase class which is set to true if health drops below 0.0f

if (Health <= 0.0f && !bDied) {
		bDied = true;

		GetMovementComponent()->StopMovementImmediately();
		GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision);

		UE_LOG(LogTemp, Warning, TEXT("Has the Character Died: %s"), (bDied?TEXT("True"):TEXT("False")))
		
	}

This method only exists in the CharacterBase class.

Within the animation blueprint, which is the same for all enemy and the game character, I would cast the owner pawn to the CharacterBase and get the value of bDied so that I can play the Death animation.
The value returned is always false!!!
If I base the enemy off CharacterBase class, then bDied is returned true and the animation plays!!

Looks like some inheritance and casting thing, although not sure if this is C++ thing or UE thing, so not sure how’d I google for this. Would really like to know what’s going on here.

Thanks,

computer restarted and it just started working, I think my VS is also playing up, keeps complaining every couple of builds that solution file not found and project not loaded and I have got to refresh VS from editor after which it starts to work.

did you declered bDies anywhere? How do you call this function?

Sorry did not see your message before…

bDied is a variable maintained on MyHeroCharacter’s header (.h) file, after the code detects that the health is <= the function just sets that to true, which is subsequently set to true in the Animation BP, which then triggers the death animation.

The function itself is registered with a custom delegate that I’ve created and gets fired everytime health changes.