I’m not 100% sure if the syntax is correct, I can’t look into my code right now (If it doesn’t work, I’ll look after it this evening). I hope this helps!
PS: If you want to totally block pitch or yaw, just set the same numbers to min and max (e.g. 90 and 90). This was my first bug when finding this solution.
It may be that it’s not quite right for your case, because my player is sitting and won’t move. Maybe you have to get the current rotation and add or subtract the 90(or whatever you wish) degrees to it. And after this, set the ViewMin and Max. Like in this pseudocode:
Otherwise it could be, that it’s better to use the upper one (without Current Rotation) in the Character tick method. This way it set’s the limitation every tick… Well you have to try it out - I’m quite new to UE4.
Great, I’m glad i could help you a bit!
Unfortunately, as I said, I’m new to UE4 and I don’t know yet how to call a “on-release-button” function. But I think there must be one. And you already have the oldYawRotation, so you would have to reverse this:
OnStopLooking()
{
APlayerController* PC = Cast<APlayerController>(GetController());
// Reverse!! now ADD the 90 degrees again to MIN
PC->PlayerCameraManager->ViewYawMin = oldYawRotation.Euler().Z + 90;
// Reverse!! now SUBTRACT the 90 degrees again from MAX
PC->PlayerCameraManager->ViewYawMax = oldYawRotation.Euler().Z - 90;
}
So you only have to figure out, how to call an event on releasing the button.
Maybe someone else can help out here?