Is it possible to toggle the visibility of a specific actor in a world?

thank you again.
And I have attempted to finish this part according to your code. But it failed because there are always Errors with LNK2019 and E1574(“TAtomic is only usable with trivial types”) while compiling. I have attempted to solve this problem by myself, but so far don’t find any solutions. Could you help me again, please? I am using UE4.24 btw.

#include “MyPlayerController.h”
#include “Kismet/GameplayStatics.h”
#include “Engine/StaticMeshActor.h”
#include “Engine/World.h”

void AMyPlayerController::ToggleVisibility()
{
TArray<AActor*> OutActors;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), AStaticMeshActor::StaticClass(), OutActors);
for (auto Current : OutActors)
Current->GetRootComponent()->ToggleVisibility(false);
}

void AMyPlayerController::SetupInputComponent()
{
Super::SetupInputComponent();

FInputKeyBinding ToggleVisibilityBinding(EKeys::One, IE_Pressed);   
ToggleVisibilityBinding.KeyDelegate.BindDelegate(this, &AMyPlayerController::ToggleVisibility);
InputComponent->KeyBindings.Add(ToggleVisibilityBinding); 

}

#pragma once

#include “CoreMinimal.h”
#include “GameFramework/PlayerController.h”
#include “MyPlayerController.generated.h”

/**
*
*/
UCLASS()
class MYPROJECT3_API AMyPlayerController : public APlayerController
{
GENERATED_BODY()

protected:

UFUNCTION()
void ToggleVisibility();

UFUNCTION()
void SetupInputComponent();

};