How to tell cast to BP in C++

I am very confused. I have a BP class that inherits from a C++ class, however the type is not the same.

So my inheritance is like this

  • APawn
  • ACharacter
  • ARPGProjectCharacter
  • ACharacterBase
  • BP_CharacterBase

======================================================
What I am trying to accomplish is when my BP_CharacterBase overlaps a health pickup, I then call an UpdateHealth(HealAmount) from a cast to ACharaterBase.

class ACharacterBase* PlayerCharacter = Cast(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));

=========================================================

Then I have the overlap where I check for PlayerCharacter that is defined above. However this is where I am having an issue. So the check is looking for ACharacterBase, but it appears ACharacterBase != BP_CharacterBase. So what is the type of BP_CharacterBase so I can do a cast and then check for it?

void AHealingPickup::OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if(OtherActor == PlayerCharacter)
{
PlayerCharacter->UpdateHealth(HealAmount);
PlayerCharacter->GetHealth();

	GEngine->AddOnScreenDebugMessage(1, 3, FColor::Yellow, FString::Printf(TEXT("Overlap Begin")));
}

You do two job here. Dont need that. Casting to cpp is also okay. Your children is already part of ACharacterBase, so basically you can do like,

void OverlapFunction(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if (ACharacterBase* PlayerCharacter = Cast<ACharacterBase>(OtherActor))
    {
          //do your algorithm
    }
}

As an advice please work on inheritance at cpp

@ctndev So your cast here is identical except the OtherActor. I still cant call functions from my CharacterBase with it that affect my BP_Character base. I guess I just cant use blueprints at all.

use add new comment under my answer. Dont type as an answer.

@ctndev So your cast here is identical
except the OtherActor. I still cant
call functions from my CharacterBase
with it that affect my BP_Character
base. I guess I just cant use
blueprints at all.

Which function do you want to call. You need to carry them to cpp as with the same name as UFUNCTION(BlueprintImplementableEvent).