I'm using the isometric ortho camera, and I'd like to limit the rotation on the Y axis, but there's no option to clamp the yaw only the pitch.

How can I go about limiting the horizontal rotation of my camera?

    WillsCreative Hi!
    I didn't put clamping settings for the Yaw rotation as usually you will want to allow it or not at all. If you don't want it at all, just uncheck the box "Allow Yaw Rotation", and place your camera with the right Y rotation you need in the scene. If you do want a rotation but only between a certain range, then yes you can add a few lines for clamping it like so:

    Open the file CameraIsometricOrtho.cs

    in the variables add:
    private bool YawClamp = true;
    public Vector2 YawMinMax = new Vector2(0.0f, 360.0f);

    then edit the ClampRotation method line 174:
    override protected void ClampRotation()
    {
    if (PitchClamp)
    currentPitch = Mathf.Clamp(Pitch, PitchMinMax.x, PitchMinMax.y);
    if (YawClamp)
    currentYaw = Mathf.Clamp(Yaw, YawMinMax.x, YawMinMax.y);
    }

      Anthony That worked perfect, very useful thank you!

      One last question; I'm setting a game object as the follow and focus when they move, and the camera follows them correctly. However if they move up and down in elevation along the move the camera is very jerky, and when they make a turn the camera wiggles almost like it's trying to spin to follow the character (2D sprite moving in a3D space). Which settings can I adjust to smoothen out the follow distance to resolve this?

        Anthony I implemented this and it seems to work fine when using one finger to rotate, but when I use 2 fingers on my device, it lets me rotate a full 360 degrees even though I have the clamp set. It seems like the TouchCameraInputs override the restrictions of the camera script on TouchCamera.

        For example, if on the TouchCamera I set the 'One Finger Drag' setting to rotate, and then try to rotate with 1 finger, it's restricted by clamp. But if I switch this setting back to translate, and then use 2 fingers to pinch and twist, I'm able to rotate full 360 degrees without a clamp

        Is there a way to adjust this so even when I use 2 fingers to rotate, it respects the clamp?

          WillsCreative Thank you, that's actually a bug.
          Here is a quick fix before I release an update on the store:

          in CameraIsometricOrtho.cs add these 2 lines after currentPitch & currentYaw lines around line 82

          ClampRotation();
          finalRotation = Quaternion.Euler(currentPitch, currentYaw, 0.0f);

          Like so

          Thanks for reporting!

            I added that code, but now when I try to rotate or touch the screen, the camera locks into a set position and i can't rotate at all (I can still zoom in and out).
            https://ibb.co/bdzBWDH

            here's a screenshot of my camera settings if it helps.

            If I set the camera input right click to drag, in the game window I can right click and move the mouse up and down, and it will rotate and pitch within the bounds. However if I try the 2 finger rotate (by holding ctrl and left clicking, or using two fingers on my device) it only zooms in and out, twist motion doesn't rotate at all.

            On my device there's no way to get the same input as right click and drag unless I set 1 finger drag to rotate... but then I can't translate

              WillsCreative Ok sorry about that, I will have a look. (I couldn't not try it yet, I just sent you what I thought should work). I'll keep you posted 😉

                Anthony Okay I figured it out, I forgot to normalize the angles.

                Add this method in the class:
                protected float NormalizeAngle(float a)
                {
                if (a > 180) a -= 360;
                if (a < -180) a += 360;
                return a;
                }

                Then use the NormalizeAngle() in the ClampRotation() method:
                override protected void ClampRotation()
                {
                if (PitchClamp)
                currentPitch = Mathf.Clamp(NormalizeAngle(currentPitch), PitchMinMax.x, PitchMinMax.y);
                if (YawClamp)
                currentYaw = Mathf.Clamp(NormalizeAngle(currentYaw), YawMinMax.x, YawMinMax.y);
                }

                I can send you the full edited script if you need. Sorry for the delay, and thanks for helping flagging the bug!

                  Thank you, this works! One more question though... how do you adjust pitch on mobile? I can use 1 finger to translate, 2 fingers to zoom and rotate... but how do I adjust the pitch?

                    WillsCreative this is why I recommend using one finger to rotate (pinch+yaw), two fingers drag to translate, and two fingers to zoom & rotate (yaw).

                    if you use 1 finger to translate I'm not sure how the user could Pitch. If you have any suggestion let me know!
                    You could have a UI slider to adjust the pitch for example. I'm not sure that 3 fingers would be intuitive at all.

                    By the way if you liked my support, please concider writing a small review on the store page 😉
                    Thanks!

                      Write a Reply...