How to Limit View/Rotation on my player character?

Hi all,

How can I limit my players view rotation?

I don’t want to be able to rotate anymore than 90 degrees left and right and up and down maybe no more than 35. Basically I 'm trying to simulate the real constraints of the human neck as far as looking around in the world goes.

So my camera is currently in the same blueprint as my player character and I have a body with a camera on the neck and again, I Just want to limit how far left and right he can look around without having to turn his body to see more.

1 Like

There are “Clamp” Nodes which define upper and lower bounds for an Input value.

1 Like

Yeah thanks, I know there are clamp nodes, I just don’t know how to use them, is there some example somewhere? I am new to blueprints

thanks alot

Yes, download the Content example from the Marketplace and open the “Math” map.

So go look at the content examples? like I haven’t already? gee thanks for your help!

2 Likes

a Basic version can be found over here:
https://answers.unrealengine.com/questions/4763/how-to-constrain-cameracontroller-rotation.html

it was answered by ue4-archive

this shows how to take the input from a character controller and restrain it to +/-100 degrees horizontally and +/- 20 degrees vertically, so, change those values as you see fit.

p.s. Don’t forget to mark questions answered.

1 Like

Thanks! i’ll take a look at it.

Well, you are implying that you have a character that looks around fine and you would like to restrict the look rotation values of said character. He handed you the answer. If you understand how the Clamp functionality works, just place it where it needs to go and you have your functionality. No need to be rude.

You did say:

I know there are clamp nodes, I just don’t know how to use them

The math map shows how to use a clamp on a vector, its a slider. so its using a float clamp, and has nothing to do with camera rotation. I came here and asked because I have go through the examples and tried to get it to work on my own without success. So coming here and trying to get help only to be told to go and look at the content examples is not at all helpful. I hope you understand that. People who just come and write 1 line responses saying go look at the example are the ones being rude.

Easy way:

void ARPGPlayerController::BeginPlay()
{
	Super::BeginPlay();
	PlayerCameraManager->ViewPitchMax = 70.0f;
	PlayerCameraManager->ViewPitchMin = -70.0f;
}
3 Likes

example, im doing the same thing, though im having issues with my pitch clamping at the moment :

Thanks Iniside this worked perfectly…this can be used to set pitch and roll limits…

12 Likes

It helped me.

I wanted my camera to also align to the pawn’s rotation, so just a small addition to this:

In your custom Pawn’s Tick, do this:

Camera->SetRelativeRotation(GetViewRotation());

And be sure to set this after creating the Camera in your constructor:

Camera->bUsePawnControlRotation = false;

Thank you!

Thank you bro u the best

Everything ingenious is simple!