Hi i would like to change the sensitivity of my Look action. So i added a Scale Vector 2 processor to it.
I can see the inputAction.processors property to read it, but im not sure how you would go about editing the x and y value of the processor.
public InputActionAsset inputActionAsset;
public InputAction Look;
void Start()
{
inputActionAsset = GameObject.FindGameObjectWithTag("EventSystem").GetComponent<InputSystemUIInputModule>().actionsAsset;
Look = inputActionAsset.FindActionMap("Player").FindAction("Look");
Debug.Log(Look.processors);// returns ScaleVector2
}
// this is attached to a UI slider
public void LookSensitivity(float sensitivity)
{
//this code doesn't work, just showing what i'd like it to do.
//Look.processors.ScaleVector2.x = sensitivity
//Look.processors.ScaleVector2.y = sensitivity
}
I do understand i could just add a look multiplier to my player at runtime, i was just curious if there is a way to edit processors directly.
I’m missing a connection here, and I cannot seem to see it. If anyone sees the mistake I’m making please let me know.
What is the thing that ties an input action reference to the input action itself? How is that connection built?
I’m in Unity 2021.3.8f1 with Input System 1.4.2, player input module > UI_EventSystem, behavior: Send Messages
For example, if I want to change the look inversion processor on a binding (It goes like this:Input Action Asset > Action Map > Action > Binding > Processor > Parameter (i.e setting) on the processor).
Here is my code:
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
public class myScript : MonoBehaviour
{
public InputActionAsset inputActionAsset; //In the Editor Property panel, drag / drop the new input system's action map from the project assets to this slot
public InputAction inputActionLook;
public InputActionReference lookAction;
void Start()
{
//Something somewhere, about here, should somehow say "lookAction refers to inputActionLook," but I don't know what does that. Do I drag something into the lookAction variable in the editor? Do I write code to do this? How is this link established?
lookAction.action.ApplyBindingOverride(new InputBinding {overrideProcessors = "invertVector2(invertX=false,invertY=false)" });
}
}
Hi. I know this was asked a while ago but I’ve tried the above code and also Rene-Damm’s code. I can’t seem to get it to work. I’ve managed to get the debug log to print out the values of the stick deadzone processor I have but I can’t change them to new values. I’ve unticked default values in the input settings just in case.
x and y are for a scaleVector. And those 0.3f and 0.9f values should of course be variables.
Alternatively, this can be written as:
using UnityEngine.InputSystem.Processors; // <- without this you won't have the preprocessor classes available
action.ApplyParameterOverride((StickDeadzoneProcessor s) => s.min, 0.3f);
action.ApplyParameterOverride((StickDeadzoneProcessor s) => s.max, 0.9f);
Are we really gonna pretend that using strings to get and apply ‘static’ stuff like processors was a good idea?
Why is there no action.GetProcessor() or action.AddProcessor() and a Processor object we can interact with?
This is some really poor thinking
Hey,
this is really not working for me. Are there any restrictions i am missing?
Also, i am using the Cinemachine Input Provider on a CinemachineFreeLook camera.
I triied many things but couldn’t manage to get it working either. Could only get the invertVector2 to work. I ended up overriding the CinemachineInputProvider class with my own version which multiplies the axis values by sensitivity
using System.Linq;
using Cinemachine;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Users;
public class CinemachineInputProviderCustom : CinemachineInputProvider
{
/// <summary>
/// Implementation of AxisState.IInputAxisProvider.GetAxisValue().
/// Axis index ranges from 0...2 for X, Y, and Z.
/// Reads the action associated with the axis.
/// </summary>
/// <param name="axis"></param>
/// <returns>The current axis value</returns>
public override float GetAxisValue(int axis)
{
if (enabled)
{
float sensitivity = SettingsManager.instance.CalculateSensitivity();
var action = ResolveForPlayer(axis, axis == 2 ? ZAxis : XYAxis);
if (action != null)
{
switch (axis)
{
case 0: return action.ReadValue<Vector2>().x * sensitivity;
case 1: return action.ReadValue<Vector2>().y * sensitivity;
case 2: return action.ReadValue<float>();
}
}
}
return 0;
}
}