# How to seperate camera from player rotation

**URL:** <https://forums.unrealengine.com/t/how-to-seperate-camera-from-player-rotation/1264189>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, CPP, Blueprint, question\
**Created:** [August 17, 2023, 6:20pm UTC](https://forums.unrealengine.com/t/how-to-seperate-camera-from-player-rotation/1264189 "2023-08-17T18:20:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HIpex\_D](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HIpex\_D](https://forums.unrealengine.com/u/HIpex_D)\
**Post date:** [August 17, 2023, 6:20pm UTC](https://forums.unrealengine.com/t/how-to-seperate-camera-from-player-rotation/1264189/1 "2023-08-17T18:20:10Z")

</div>

I am making first person game and when I look up or down my player just straight up rotates 90°. This also makes moving impossible while looking up or down.

Is there a way to keep my player character Y rotation locker while looking up or down?

I made input in in c++:

```auto
// Fill out your copyright notice in the Description page of Project Settings.

#include "PController.h"
#include "EnhancedInputComponent.h"
#include "PCharacter.h"

void APController::OnPossess(APawn* aPawn)
{
	Super::OnPossess(aPawn);

	PlayerCharacter = Cast<APCharacter>(aPawn);
	checkf(PlayerCharacter, TEXT("Something is worng."));

	EnhancedInputComponent = Cast<UEnhancedInputComponent>(InputComponent);
	checkf(EnhancedInputComponent, TEXT("Something is worng."));

	UEnhancedInputLocalPlayerSubsystem* InputSubsystem =
		ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer());
	checkf(InputSubsystem, TEXT("Something is worng."));

	InputSubsystem->ClearAllMappings();
	InputSubsystem->AddMappingContext(InputMappingContext, 0);

	if(ActionMove)
	{
		EnhancedInputComponent->BindAction(ActionMove, ETriggerEvent::Triggered, this, &APController::HandleMove);
	}
	if (ActionLook)
	{
		EnhancedInputComponent->BindAction(ActionLook, ETriggerEvent::Triggered, this, &APController::HandleLook);
	}
	if (ActionJump)
	{
		EnhancedInputComponent->BindAction(ActionJump, ETriggerEvent::Triggered, this, &APController::HandleJump);
	}
	if (ActionRun)
	{
		EnhancedInputComponent->BindAction(ActionRun, ETriggerEvent::Triggered, this, &APController::HandleRun);
		EnhancedInputComponent->BindAction(ActionRun, ETriggerEvent::Completed, this, &APController::HandleRunRelease);
	}
	if (ActionCrouch)
	{
		EnhancedInputComponent->BindAction(ActionCrouch, ETriggerEvent::Triggered, this, &APController::HandleCrouch);
		EnhancedInputComponent->BindAction(ActionCrouch, ETriggerEvent::Completed, this, &APController::HandleCrouchRelease);
	}
}

void APController::OnUnPossess()
{
	EnhancedInputComponent->ClearActionBindings();
	Super::OnUnPossess();
}

void APController::HandleMove(const FInputActionValue& InputActionValue)
{
	const FVector2D MovementVector = InputActionValue.Get<FVector2D>();

	if (PlayerCharacter)
	{
		PlayerCharacter->AddMovementInput(PlayerCharacter->GetActorForwardVector(), MovementVector.Y*PlayerCharacter->MoveForwardRate);
		PlayerCharacter->AddMovementInput(PlayerCharacter->GetActorRightVector(), MovementVector.X*PlayerCharacter->MoveRightRate);
	}
}

void APController::HandleLook(const FInputActionValue& InputActionValue)
{
	const FVector2D LookAxisVector = InputActionValue.Get<FVector2D>();

	if (PlayerCharacter)
	{
		AddYawInput(LookAxisVector.X * PlayerCharacter->LookRightRate);
		AddPitchInput(LookAxisVector.Y * PlayerCharacter->LookForwardRate);
	}
}

void APController::HandleJump()
{
	if(PlayerCharacter)
	{
		PlayerCharacter->UnCrouch();
		PlayerCharacter->Jump();
	}
}

void APController::HandleRun()
{
	if(PlayerCharacter)
	{
		PlayerCharacter->MoveForwardRate = 2.f;
		PlayerCharacter->MoveRightRate = 2.f;
	}
}

void APController::HandleRunRelease()
{
	if (PlayerCharacter)
	{
		
		PlayerCharacter->MoveForwardRate = 1.f;
		PlayerCharacter->MoveRightRate = 1.f;
	}
}

void APController::HandleCrouch()
{
	if(PlayerCharacter)
	{
		PlayerCharacter->Crouch();
	}

}

void APController::HandleCrouchRelease()
{
	if (PlayerCharacter)
	{
		PlayerCharacter->UnCrouch();
	}

}

```

---

<div class="post-metadata">

**Author:** ![Bryondr](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bryondr/32/743155_2.png) [@Bryondr](https://forums.unrealengine.com/u/Bryondr)\
**Post date:** [August 17, 2023, 7:29pm UTC](https://forums.unrealengine.com/t/how-to-seperate-camera-from-player-rotation/1264189/2 "2023-08-17T19:29:02Z")

</div>

Go to your Character Blueprint and make sure these are not checked for **Pawn**

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/2/4/e24935b2c102960065ae19882f0a11ef4726c518.png)

---

<div class="post-metadata">

**Author:** ![AreWeGaming](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arewegaming/32/1174860_2.png) [@AreWeGaming](https://forums.unrealengine.com/u/AreWeGaming)\
**Post date:** [August 18, 2023, 12:01am UTC](https://forums.unrealengine.com/t/how-to-seperate-camera-from-player-rotation/1264189/3 "2023-08-18T00:01:28Z")

</div>

If you just want the camera to move the character left and right and not up and down Do that ^^^ but also on the Camera Check Use Control Rotation

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [September 17, 2023, 12:02am UTC](https://forums.unrealengine.com/t/how-to-seperate-camera-from-player-rotation/1264189/4 "2023-09-17T00:02:16Z")

</div>

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