Forum rules - please read before posting.

Mouse sensitivity option with new input system

How would I go around making a mouse sensitivity option when using the new input system?

Comments

  • edited November 2023

    In what context - when moving a First / Third-person camera?

    If so, it's the CursorHorizontal / CursorVertical inputs you're dealing with - you can check this by applying a "Scale" Processor to them in the Controls asset. Is this Scale value what you're looking to set dynamically?

  • Yes, I want to give players the option to adjust the sensitivity of first-person camera movement.

  • OK. Add a Scale processor as above, and then use this component (ScaleProcessorLink.cs) to link it to a Global Float Variable:

    using UnityEngine;
    using UnityEngine.InputSystem;
    using UnityEngine.InputSystem.Processors;
    using AC;
    
    public class ScaleProcessorLink : MonoBehaviour
    {
    
        [SerializeField] private string actionName = "CursorHorizontal";
        [SerializeField] private string globalStringVariableName = "Sensitivity";
        [SerializeField] private UnityEngine.InputSystem.PlayerInput playerInput;
        private GVar globalStringVariable;
    
        private void Update ()
        {
            if (globalStringVariable == null)
            {
                globalStringVariable = GlobalVariables.GetVariable (globalStringVariableName);
            }
            if (globalStringVariable != null)
            {
                var action = playerInput.actions.FindAction (actionName);
                action.ApplyParameterOverride ((ScaleProcessor p) => p.factor, globalStringVariable.FloatValue);
            }
        }
    
    }
    

    If you then set the Global Variable's Link to field to Option Data, it's value will be stored as part of the profile, rather than any individual save file.

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.