Camera can't rotate in game but can rotate in game.

Development Environment: UE5.3.2, C++, Windows10, Rider.

Purpose: I want the camera to always face the Actor in the game, in the same direction as the Actor. At the same time, keep a certain distance from the Actor.

In the C++ code, I created a Pawn, bound SceneCoponent and USpringArmComponent and UCameraComponent. Just like below:


In the C++ code I have set the following properties but don’t know what I am missing and the camera is not working.

	MySceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("MySceneComponent"));
	RootComponent = MySceneComponent;
	
	CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
	CameraBoom->SetupAttachment(RootComponent);
	CameraBoom->TargetArmLength = 4000.0f; 
	CameraBoom->bUsePawnControlRotation = true; 


	CameraComponent = CreateDefaultSubobject<USquintCameraComponent>(TEXT("CameraComponent"));
	CameraComponent->SetupAttachment(CameraBoom);
	CameraComponent->bUsePawnControlRotation = true;

	bUseControllerRotationPitch = false;
	bUseControllerRotationYaw = false;
	bUseControllerRotationRoll = false;

It should be noted that in the editor, I can see the camera change by changing the Yaw value, but not in the game.

Can anyone help me, thank you very much!

I have solved this bug. It was caused by my poor English, I thought it meant to make my component controlled by pawn. In fact, it made my Pawn controlled by the Controller.
So,
bUsePawnControlRotation should be FALSE

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.