Disable Player/Player Camera Movement

Hello, I’m having difficulty disabling the player/player camera from rotating when the player moves the mouse. I am using the C++ FPS Template. Basically all I am trying to achieve is for when the player presses “Q” the mouse no longer rotates the player/player camera. This is what I have so far in the character class.

void AASF_PrototypeCharacter::TurnAtRate(float Rate)
	// calculate delta for this frame from the rate information
	if (bCameraMovement == true) {
		AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds());

	else {

void AASF_PrototypeCharacter::LookUpAtRate(float Rate)
	// calculate delta for this frame from the rate information
	if (bCameraMovement == true) {
		AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds());

	else {

bCameraMovement is a boolean that is changed when the player presses and releases “Q”, which is working as I’ve done debugging. Any tips/hints on what to do is welcomed, and I can post more of the code if needed.

Have you tried running it without the else statement?

bCameraMovement is a boolean that is changed when the player presses and releases "Q"

So when you release Q bCameraMovement is being set to true again?

Yes, it is set back to true, and I’ve tried it without the else statement.

When you release the Q button your bCameraMovement is set back to true. This means you will enter the if statement’s body and you’ll have pitch and yaw control.

I recreated what you tried. I was using a blank c++ project but I don’t think it makes a difference. It worked for me:
Line 187-203:**

Set bCameraMovement on line 58:**


Yeah I’m not sure what is going on. I’ve completely disabled the TurnAtRate and LookUpAtRate functions and my player still rotates with mouse movement. Seems like the player is being rotated somewhere else but I can’t find it.

I’m going to load the C++ template and have a look into it. Give me a sec.

Your Mouse controlled camera functions are using the built in functions AddControllerYawInput() and AddControllerPitchInput(). The TurnAtRate() and LookUpAtRate() functions are being used for a controller or your arrow keys.

See project settings axis mappings:


And which functions are binded - Line 68-75 -


You would want to write your own functions which control the camera pitch and yaw input

Step 1:


Step 2:


Step 3:


Step 4 (Note that you now use the function from your Character class and not from APawn!):


Now if you were to check if(bCameraMovement) it should work. Note: I noticed in project settings->input->Axis Mapping->Look Up->Mouse Y is set to -1. This means the mouse is inverted by default. Either get rid of n8MouseInvertion, set n8MouseInvertion to 1 or set Look Up->Mouse Y in project settings to 1.0.

lol I can’t believe I didn’t notice I was just turning off the rotation for controllers. Thanks a lot! And and extra thank you for creating that nice little tutorial.

No problem :-).

Why reinvent the wheel when you don’t have to? Rather than rewriting Camera functions you can just set the Pitch, Yaw, and Roll in the player control to Zero and then reset to the previous values.


This is just an example in Blueprints, but I’d imagine it’d be pretty similar in C++.