Forum rules - please read before posting.

Camera pitch option like mousewheel zooming for distance

Hi Chris,

AC 1.69.2
Unity 2017.4.31f1

I'm hoping there is an easy way, or even implement it within AC itself,

Similarly how we can use Mousewheel zooming option for the distance, would really appreciate the option to adjust the pitch the same way with a slight difference, example Ctrl+Mousehweel adjusts the pitch, and just mousewheel adjusts the distance.

If you don't think it should be within AC any chance you can help me with the code please? Really like how the mousewheel for the distance part works,

Thank you

Comments

  • edited September 2019

    This is for what, the GameCamera Third Person?

    Pitch is controlled via the Input axis you define in the Inspector, but this axis is processed by AC's PlayerInput script - meaning you can implement an override as covered in the Manual's "Remapping inputs" chapter.

    Try this script (CustomCameraInput.cs):

    using UnityEngine;
    using AC;
    
    public class CustomCameraInput : MonoBehaviour
    {
    
        void Start ()
        {
            KickStarter.playerInput.InputGetAxisDelegate = CustomGetAxis;
        }
    
        private float CustomGetAxis (string axisName)
        {
                if (axisName == "CameraPitch")
                {
                    if (Input.GetButton ("Control"))
                    {
                        return Input.GetAxis ("Mouse ScrollWheel");
                    }
                    return 0f;
                }
            try
            {
                return Input.GetAxis (axisName);
            }
            catch {}
            return 0f;
        }
    
    }
    

    Attach that to your camera and define a new input in Unity's Input Manager named "Control", and map it to "left ctrl". Then in the Third Person Camera's Inspector, set the pitch axis input name to "CameraPitch".

  • Hi Chris,

    Yes it is for the ThirdPerson Camera

    I am stuck at the: return Input.GetKey ("Mouse ScrollWheel"); due to this error:

    error CS0029: Cannot implicitly convert type bool' tofloat'

    Unsure how to fix it

  • Worthy to note that I put a debug log:

            if (Input.GetButton ("Control"))
            {
                Debug.Log("test");
            }
    

    And even though Control is pressed there is no Debug Test

    I'm not sure how this will actually change the pitch of the camera?

  • edited September 2019

    Chris,

    I have this script from the past when you helped me to have free look,

    Is there any way we can simply for example if its free looking but also control button down to save the values for pitch/spin?

    I'm gonna try take a stab at it, but I assume it has to do with when its in free look, (rotation.locked free for pitch/spin) and Control down, change the values on the camera maxPitch and spinrotation :)

    Might be the easiest route

    So far, I don't know how to convert the free rotation positions/rotations to values to set them to the spin/pitch.

  • I've amended the above script with a fix for the "bool to float" error.

    A different custom script can certainly alter the maxPitch etc settings, since the variables are all public.

    And even though Control is pressed there is no Debug Test

    Then either the component is not attached to the camera, your camera's pitch axis is not set to "CameraPitch", or the Control input is not defined in your Input settings. Share images if you'd like help debugging.

    I'm not sure how this will actually change the pitch of the camera?

    This works by overriding the result of input checks for "CameraPitch". If this input's value is requested, it first checks to see if the "Control" button is pressed, and only if so - returns the value of the "Mouse ScrollWheel" axis (which must also be defined in the Input Manager. "CameraPitch" is a dummy input used only through script, so it does not need to be added.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.