I want to use 9 cameras in total. 8 cameras, because of th 8 views and a 9th camera for showing the scene from the top.
So, I assign the 8 cameras as shown using the “Auto Activate” from the editor.
for the 9th camera I am doing the same thing, but from c++, since the editor only allows us to do this for up to 8 cameras.
I am searching for the correct cameras by name like this within my custom GameMode:
for (TObjectIterator<ACameraActor> Itr; Itr; ++Itr) {
ACameraActor *actor = *Itr;
if (actor->GetWorld() == GetWorld()) {
const FString actorName = actor->GetName();
if(actorName.Equals("SpectatorCamera")) {
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Cyan, actorName);
SpectatorCamera_ptr = actor;
}
}
once I have found the CameraActor, I do this:
APlayerController* PlayerControllerPtr = UGameplayStatics::GetPlayerController(GetWorld(), 8);
GetWorld()->RegisterAutoActivateCamera(SpectatorCamera_ptr, 8);
if(PlayerControllerPtr) {
PlayerControllerPtr->SetViewTarget(SpectatorCamera_ptr);
}
I found this within the source code of ACameraActor