this is purely a performance question. I want to add actors to a array and remove them when the player enters a area or leaves it. currently I would cast to the player 100+ times. I don’t want that for performance reason. what else could I do instead of casting.
Actor to add to array on player:
void AInteractableActor::RegisterActor()
{
ATopDownCharacter* character = Cast<ATopDownCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
if (character != NULL)
{
switch (ActorTypeEnum)
{
case EActorTypeEnum::****:
character->*****(this);
break;
case EActorTypeEnum::***:
character->****(this);
break;
}
}
else
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("unable to find player"));
}