bUsePawnControlRotation 's problem

in Unreal Tutorial, PlayerCharacter has CameraComponent and SpringArmComponent

So at SpringArmComponent->bUsePawnControlRotation = false,

Pawn is same PlayerCharacter, Directly Connect.

but in my code, something is difference and the difference makes a problem.

MyCharacter has AMyCameraActor Class as member value point like this.

MyPlayerCharacter.h

AMyCameraActor* m_pCameraActor;

also, this AMyCameraActor has CameraComponent and SpringArmComponent.

resultingly between AMyCharacter and SpringArmComponent, middle class exist “AMyCameraActor”.

it seem good, in my opinion.

but problem is about “bUsePawnControlRotation” .

because AMyCameraActor has SpringArmComponent, SpringArmComponent’s Pawn is AMyCameraActor not AMyCharacter.

although i set bUsePawnControlRotation false

it doesn’t work

how to handle this matter?

of course, I set values in AMyCharacterScript

GetCharacterMovement()->bOrientRotationToMovement = true;

bUseControllerRotationYaw = false;

bUseControllerRotationPitch = false;

bUseControllerRotationRoll = false;

//ACamera.h

UCLASS()
class FRAMEWORK_API AFrameWorkCamera : public AActor

{

	GENERATED_BODY()
	
public:
	UCameraComponent* m_pCameraCom;
	USpringArmComponent* m_pSpringArm;

public:	
	AFrameWorkCamera();

	virtual void BeginPlay() override;
	
	virtual void Tick( float DeltaSeconds ) override;
};

//ACamera.cpp

AFrameWorkCamera::AFrameWorkCamera()
: Super()

{

PrimaryActorTick.bCanEverTick = true;

m_pSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("OurCamera"));
m_pSpringArm->AttachTo(RootComponent);
m_pSpringArm->bAbsoluteRotation = true;
m_pSpringArm->TargetArmLength = 800.f;

    m_pCameraCom = CreateDefaultSubobject("CameraComponent");
m_pCameraCom->AttachTo(m_pSpringArm);
m_pCameraCom->bUsePawnControlRotation = false;

}

//ACharacter.h

UCLASS()
class FRAMEWORK_API AFrameWorkCharacter : public ACharacter

{

GENERATED_BODY()

public:

UPROPERTY(EditAnywhere)

AFrameWorkCamera* m_pCamera;

public:

};

//ACharacter.cpp
void AFrameWorkCharacter::BeginPlay()

{

Super::BeginPlay();

if (!m_pCamera)

{

	FVector ActorLocation = this->GetActorLocation();

	FVector RelativeLocation = FVector(
		ActorLocation.X,
		ActorLocation.Y,
		ActorLocation.Z);

	m_pCamera= (AFrameWorkCamera*)GetWorld()->SpawnActor(AFrameWorkCamera::StaticClass(),
		&RelativeLocation);


	m_pCamera->AttachRootComponentToActor(this);


	APlayerController* OurPlayerController = UGameplayStatics::GetPlayerController(this, 0);
	if(OurPlayerController)
		OurPlayerController->SetViewTargetWithBlend(m_pCamera, 0.75f);
}

}

Code is so simple,

Character has CameraActor

and

CameraActor has two Component(Camera,SpringArm)

Hey 1205-

What class is AMyCameraActor based on? Can you post the full code for the AMyCameraActor class so that I can ensure my setup matches what you’re using?

The easiest solution would be to add the SpringArmComponent and the CameraComponent directly to the character rather than adding them to another class/component that is then being added.

Cheers

i am finding problem solution, staying this class structure… T-T

ah, i add code m_pCamera->AttachRootComponentToActor(this) in Character’s BeginPlay

i change upper comment code

Hey 1205-

Were the changes you made enough to get the camera working correctly for you? If you are still having problems with the camera setup then I would suggest adding the camera component and the spring arm component directly to the character class and using CreateDefaultSubobject in the character constructor for both.

Cheers