Set Main Camera View

Hi guys, I put a static Camera in the Scene. What I want is the main view to be the view of this camera. I don’t want the camera to follow my player or have any target. I want just a camera that sees the scene from a static place. How can I do that? Right know when I press the Play button the main view is the view of the Player Starter, I want to change that.

SetViewTarget function in PlayerController

Thanks mate, I will try this out when I get home, and will tell you what happened :slight_smile:

Also to add, this function set camera to camera component in actor, you can input any actor and it will use camera component of that actor, similar as in spectator mode you can switch between players cameras in some games :wink:

Mate, I don’t get it. I have to inherit APlayerController and to call the SetViewTarget function to target the static camera?

Either PlayerCameraManager->SetViewTarget(ACharacter); // in APlayerConller
or through blueprint with Set View Target with Blend

Set View Target with Blend is diffrent funtion and SetViewTarget is in PlayerController too

You need to call it in player controller. You dont know how to get yor player controller?

Ok, I managed to do it both with C++ code and with a blueprint.

Here is how it’s done with C++

// Header
UCLASS()
class ACameraController : public AActor
{
	GENERATED_UCLASS_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View Target")
	ACameraActor* ViewTarget;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Player Controller")
	APlayerController* PlayerController;

	virtual void BeginPlay() override;
};

// Source
ACameraController::ACameraController(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
}

void ACameraController::BeginPlay()
{
	Super::BeginPlay();

	this->PlayerController = this->()->GetFirstPlayerController();
	if (this->PlayerController && this->ViewTarget)
	{
		this->PlayerController->SetViewTarget(this->ViewTarget);
	}
}

This answer shows how it’s done with a blueprint