Specify Actor for SetViewTarget() - How?

Hello, bear with me because this is a pretty basic question.

I placed a CameraActor with a CameraComponent (done via C++) in my level.
As soon as the game starts, I want every player to “see through” this camera.

EDIT:
I’ve changed my camera and it is now loaded with the level, not spawned during runtime.
How’s the syntax for the SetViewTarget() function if I wan’t to set the view target of the playercontroller to this camera?
Here’s my code:

CameraActor.Header

UCLASS()
class PONG_API APongCameraActor : public AActor
{
	GENERATED_BODY()


public:
	APongCameraActor(const FObjectInitializer& ObjectInitializer);

	//Camera Component
	UPROPERTY()
	class UCameraComponent *pongCamComponent;

};

CameraActor.Source

APongCameraActor::APongCameraActor(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{

	pongCamComponent = ObjectInitializer.CreateDefaultSubobject<UCameraComponent>(this, TEXT("PongCameraComponent"));
	RootComponent = pongCamComponent;
	pongCamComponent->Activate();

}

PlayerController.Source

void APongPlayerController::BeginPlay()
{
	Super::BeginPlay();
	FString fInPC = "In PlayerController";
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, (fInPC));


	PrintAllStaticMeshActorsLocations();

	//SetViewTarget - How do I reference my CameraActor here?
	//SetViewTarget();

}

Thanks for your time and help!

EDIT:
solved it, I simply set it directly as a variable.

AActor *pongCam = ()->SpawnActor<APongCameraActor>(APongCameraActor::StaticClass());

smh

You simply set view target of player controller to specific actor. View target (which is actor) will will run CalcCamera function on every frame which modifies player camera position, by default (and ofcorse you can only change that in C++) it searches for last camera component in actor and set postion of player camera to it

void AActor::CalcCamera(float DeltaTime, FMinimalViewInfo& OutResult)
{
    if ([bFindCameraComponentWhenViewTarget](API\Runtime\Engine\GameFramework\AActor\bFindCameraComponentWhenViewTarg-))
    {
        // Look for the first active camera component and use that for the view
        TArray<UCameraComponent*> Cameras;
        GetComponents<UCameraComponent>(/*out*/ Cameras);
 
        for (UCameraComponent* CameraComponent : Cameras)
        {
            if (CameraComponent->bIsActive)
            {
                CameraComponent->GetCameraView(DeltaTime, OutResult);
                return;
            }
        }
    }
 
    GetActorEyesViewPoint(OutResult.Location, OutResult.[Rotation](API\Runtime\Engine\Camera\FMinimalViewInfo\Rotation));
}

So to change that behavior you need to overriding your function in your actor

But i think easier option for you is to place CameraActors and assign each player to single one and set them as view targets for each

EDIT: I edited my first post.

can you show me that beginplay?

Hey blueshifted-

It sounds like you were able to solve your issue by setting your camera actor as a variable. I am marking this post as resolved since it seems you are no longer having any problems with the reported issue. If you are still having any problems with setting up your cameras properly please feel free to reopen this post.

Cheers