Hi, How to do this properly in C++. I first created the variable of type BP_BaseCharacter and later get the BP_BaseCharacter class and sets the variable CharacterRef.
**
It’s safest to use IsValid(Character) instead of checking against nullptr only.
Can be written as:
ABaseCharacter* CharacterRef = Cast<ABaseCharacter>(UGameplayStatics::GetPlayerCharacter(this, 0));
if (IsValid(CharacterRef))
{
// this is OK
}
else
{
return;
}