Setting custom camera C++

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.

  1. WHat spawns the default camera actor and how can I stop this?

  2. 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)));

	for (auto Iterator = GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator)
		APlayerController* poPlayerCont = *Iterator;

I will be using my own custom camera down the track so I need this to work.

Any help would be appreciated.

Camera Actors are not really meant to be used as player cameras. If you really wanted to go that route, you should at least use a simple Camera Component, since the actor is just a container for that.

But the recommended way of doing it is to subclass PlayerCameraManager. Then change PlayerCameraManagerClass in your player controller to your newly created camera manager class. Inside that camera manager, you can pretty much do anything you want. There also is a fair amount of camera/view settings in PlayerController itself.

Camera management is a bit hard to follow, but this should get you started.


Ty, I got it sorted. Created my own player controller and set bAutoManageActiveCameraTarget to false.