I have declared a EditAnywhere FName TriggerTag variable.
With that you can easily reuse the same Plate for other Trigger to activate or deactivate, f.e. crates or stone which could be set by the player.
to make it a lil bit more save when no TriggerTag is set i used an early return
if (TriggerTag == "")
{
return;
}
else
{
for (int ActorIndex = 0; ActorIndex < OverlappingActors.Num(); ++ActorIndex)
{
AActor* A = OverlappingActors[ActorIndex];
/*FString Msg = FString::Printf(TEXT("Name: %s"), *A->GetName());
GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::White, Msg);*/
if (A->ActorHasTag(TriggerTag))
{
TriggerActor = A;
break;
}
}
if (TriggerActor)
{
if (!Activated)
{
Activated = true;
GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::White, TEXT("Activated"));
}
}
else
{
if (Activated)
{
Activated = false;
GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::White, TEXT("Deactivated"));
}
}
}
I really don´t like anything string based hardcoded