3rd person template camera (LookUp) problem

I’ve tried to get a basic camera set up for a character simply copying the template camera made by UE4. I don’t get how it works. I can get the whole character together with the camera/spring arm to turn around using APawn::AddControllerYawInput(), but it is supposed to not rotate the whole character.

The most problematic thing is, that APawn::AddControllerPitchInput() doesn’t seem to do anything. I’ve tried setting different inputs to activate it, and it simply won’t bother moving the camera. I then started a new project inserting almost nothing but the camera set up from the template,

From the Character .h,

class SHOOTERSTRAT_API APlayerCharacter : public ACharacter

	// Sets default values for this character's properties

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;

	/* Camera							*/

	/** Base turn rate, in deg/sec. Other scaling may affect final turn rate. */
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera", meta = (AllowPrivateAccess = "true"))
	float BaseTurnRate;

	/** Base look up/down rate, in deg/sec. Other scaling may affect final rate. */
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera", meta = (AllowPrivateAccess = "true"))
	float BaseLookUpRate;
	UPROPERTY(EditAnywhere, Category = "Camera")
	class USpringArmComponent* PlayerCameraBoom;
	class UCameraComponent* PlayerCamera;

	* Called via input to turn look up/down at a given rate.
	* @param Rate	This is a normalized rate, i.e. 1.0 means 100% of desired turn rate
	void LookUpAtRate(float Rate);

	/** Returns CameraBoom subobject **/
	FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return PlayerCameraBoom; }
	/** Returns FollowCamera subobject **/
	FORCEINLINE class UCameraComponent* GetFollowCamera() const { return PlayerCamera; }


From the Character .cpp,

	PrimaryActorTick.bCanEverTick = false;

	// Set size for collision capsule
	GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);

	// Configure character movement
	GetCharacterMovement()->bOrientRotationToMovement = true; 
	GetCharacterMovement()->RotationRate = FRotator(0.0f, 540.0f, 0.0f);
	GetCharacterMovement()->JumpZVelocity = 600.f;
	GetCharacterMovement()->AirControl = 0.2f;

	/* Camera							*/

	// set our turn rates for input
	BaseTurnRate = 45.f;
	BaseLookUpRate = 45.f;

	// Don't rotate when the controller rotates. Let that just affect the camera.
	bUseControllerRotationPitch = false;
	bUseControllerRotationYaw = false;
	bUseControllerRotationRoll = false;

	// Set up camera boom
	PlayerCameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("PlayerCameraBoom"));
	PlayerCameraBoom->TargetArmLength = 300.f;		// Set boom length
    // Rotate the arm based on the controller
	PlayerCameraBoom->bUsePawnControlRotation = true; 

	PlayerCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("PlayerCamera"));
	PlayerCamera->AttachTo(PlayerCameraBoom, USpringArmComponent::SocketName);	
	PlayerCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm


I removed/changed some of the comments (And excluded some unnecessary parts of the code) because of formatting, but basically it’s just a copy of the 3rd person template camera.
I really don’t see what I am missing.
I thought the,

    	// Don't rotate when the controller rotates. Let that just affect the camera.
    	bUseControllerRotationPitch = false;
    	bUseControllerRotationYaw = false;
    	bUseControllerRotationRoll = false;

would make sure the character wouldn’t rotate along with the camera, but I guess I am wrong. It compiles fine, by the way.

In short: What is missing for the upwards rotation of the camera, and for the camera to rotation without affecting the character (When no movement input), like in the third person template?

Sorry if this is a vague question.

Hello Boooke,

I can’t see why this isn’t working for you. Could you post the code for the SetupPlayerInputComponent function call in your .cpp file? I’m assuming you copied majority of it from the template but I want to be sure.

Thanks for the answer. I actually meant to add it. Must’ve forgotten it.
Anyways, it is as following:

// Called to bind functionality to input
void APlayerCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
    	// Works
    	InputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);			
        // Can't get it working
    	InputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);		

        // Not in use
    	InputComponent->BindAxis("LookUpRate", this, &APlayerCharacter::LookUpAtRate);	

I did not write or copy any movement input to just focus on the camera.

Also, I’ve tried to add the source to github:
I am completely new to Github, so I am not completely sure if I did it right. Anyways, this is all of the code, which is indeed pretty much copied parts of the template.

Hello Boooke,

You were on the right track with these lines.

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

After I set up the class with just the input then made a blueprint based off it, added a mesh/spring arm/camera and I was seeing the same results. I then added those three lines and no difference. It seems that the blueprint didn’t want to automatically update based off that since it already existed and the lines were in the construction script.

I searched “Control” in the details panel with the self selected in components and noticed that Pitch was still on, but it acknowledged that wasn’t the default via the yellow arrow beside it. After changing that, everything worked as you’re expecting.

You should be able to switch that and be good to go.

Hope this helps!

Thank you so much. This will help me in many, otherwise for me impossible, situations I imagine.

I noticed many of the changes in code were unchanged in the blueprint after you mentioned it. I did create the blueprint before writing much of the code, so I take the blueprint won’t normally update after a change in the code (Or at least the constructor?). Is there a way to update the blueprint automatically?

I put a bug report in for that exact issue yesterday but I was under the impression at the time that it was only for values that were created in the class, rather than any variable being set in the construction script. It could be intended but there is a report for it so we’ll just have to see.