I’m just starting in Unreal Engine 4.
I’m trying to spawn a camera and set it as the view in C++. I can spawn the camera just fine, however when simulation begins there are TWO camera’s in the scene (so… one is being spawned by something). The first is unmanaged by me and used as the default veiw. I want to get rid of the first camera being spawned, spawn my own and set it as the veiw.
-
WHat spawns the default camera actor and how can I stop this?
-
Why does this code not set my camera view?
void AMyGameMode::BeginPlay()
{
UWorld* poWorld = GetWorld();
ACameraActor* poCameraActor = poWorld->SpawnActor<ACameraActor>();
poCameraActor->GetCameraComponent()->ProjectionMode = ECameraProjectionMode::Orthographic;
poCameraActor->GetCameraComponent()->OrthoWidth = 512.0f;
FTransform transform(FVector(0.0f, 0.0f, 1000.0f));
transform.SetRotation(FQuat::MakeFromEuler(FVector(0.0f, -90.0f, 0.0f)));
poCameraActor->SetActorTransform(transform);
poCameraActor->GetCameraComponent()->Activate();
for (auto Iterator = GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator)
{
APlayerController* poPlayerCont = *Iterator;
poPlayerCont->SetViewTarget(poCameraActor);
}
}
I will be using my own custom camera down the track so I need this to work.
Any help would be appreciated.