I’ve been reading to find a way to clamp my player’s camera pitch to -45/60 strictly in code, I’ve searched everywhere on the interwebs and I only see blueprints, it can be done in BPs but I prefer to hardcore it to my playerclass instead of fiddling around with hacks on BPs. Anyways what would be the best approach for this? I’ve read up on FMath::Clamp / FRotator Clamp(), but the documentation is not helping me at all, this is what I’ve done.
Are you sure you’re using a CameraComponent? Out of the box, the default camera is managed using PlayerCameraManager.
Incidentally, that is where you would easily clamp camera angles:
/** pitch limiting of camera facing direction */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PlayerCameraManager)
float ViewPitchMin;
/** pitch limiting of camera facing direction */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PlayerCameraManager)
float ViewPitchMax;
/** yaw limiting of camera facing direction */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PlayerCameraManager)
float ViewYawMin;
/** yaw limiting of camera facing direction */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PlayerCameraManager)
float ViewYawMax;
/** roll limiting of camera facing direction */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PlayerCameraManager)
float ViewRollMin;
/** roll limiting of camera facing direction */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PlayerCameraManager)
float ViewRollMax;