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?
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.
Comments
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:
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.