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!