How to create a free camera ?

Hello everybody,

I am a little desparate, I’ve been trying to control a camera in c++ since two weeks. I would like to know how to change the location, the rotation and the fov in running time.

I’ve tried with SetActorLocation() on a CameraActor, the coordinates change but not the view.
I’ve also tried with SetFOV() of the player camera manager of the player controller and nothing change.
And other many things.

Can anyone help me ? My english is very bad (I’m french), I probaly missed a lot of things in documentation.

Also I have some questions :

  • A camera actor must be a componant of another actor to be moved ?
  • What realy is the target view ? I used the function SetTargetView(camera) to chose which camera to watch.

Thank you in advance for your help and I’am sorry for my bad english.

Here is 2 solutions to controls the camera location and rotation :

1- Via PlayerCameraManager (Don’t Forget to set it in your Playercontroller as DefaultPlayerCameraManager) :

here you dont have to care about the camera setted as default view target

.h
ACameraManager : public APlayerCameraManager

// Let say it's equivalent to Tick
virtual void UpdateViewTargetInternal(FTViewTarget& OutVT, float DeltaTime) override;

.cpp

void ACameraManager::UpdateViewTargetInternal(FTViewTarget& OutVT, float DeltaTime)
{
	AActor* MyNewTarget;
	FVector MyNewLocation;
	FRotator MyNewRotation;
	float MyNewFOV;


	OutVT.POV.Location = MyNewLocation;
	OutVT.POV.Rotation = MyNewRotation;
	OutVT.POV.FOV = MyNewFOV;
	OutVT.SetNewTarget(MyNewTarget);
}

2 - By Using a CameraActor (an Actor + CameraComponent) to use SetActorLocation , Rotation change CameraComponent values…

// For example in your camera actor beginplay
GetWorld()->GetFirstPlayerController()->SetViewTarget(this);

Thank you for your answer ! It works.