How can I have the exact same values given by the Input.GetAxis(“Horizontal”) that every project has set up by default in Unity in the new Input system?
I can’t seem to reproduce the same values.
How can I have the exact same values given by the Input.GetAxis(“Horizontal”) that every project has set up by default in Unity in the new Input system?
I can’t seem to reproduce the same values.
var myInputAction = inputMap.AddAction("Horizontal");
myInputAction.AddCompositeBinding("Axis")
.With("Negative", <Keyboard>/a)
.With("Positive", <Keyboard>/d);
myInputAction.passThrough = true;
Or, do the same with object in inspector
I should have specified that I want this for a gamepad my bad. Do you know how to replicate the gamepad’s horizontal/vertical axis?
I set the action type to Pass through and the control type to Axis with the left stick[gamepad].
However the behaviour is just not the same as the Input.GetAxis(“horizontal”)/(“vertical”) standard to Unity.
This is because the input returned by the new input system when I stop holding the joystick is not zero: Sometimes, there is some small value left over like 0.0043.
I tried to add a processor with Axis Deadzone with a min of 0.1 but it doesn’t change anything.
Here’s how I read it in code:
public void OnMove(InputAction.CallbackContext context)
{
MoveAxis = context.ReadValue<Vector2>();
Debug.Log("OnMove: " + MoveAxis.ToString("#.#####"));
}
And here’s the debug line it gives me when I stop holding the joystick.
OnMove: (.02975, -.03459) ----> Non-zeroed.
I did the same thing but in the inspector, but the values are fixed, meaning when I press A I get an output of (-1) and (1) if i press D, i want it to gradually go back to zero, how to do that ?
There’s no support for this ATM. Stateful processors are on the list for >1.0.
What gamepad are you using? When letting go of the stick, the value should go back to (0,0). If it doesn’t, that would be a bug. What value are you seeing in the input debugger?
I’m using an XBOX controller and what I see in the input debugger is the line here:
I looked at one of your demos in the projects available (in the PackageManager) and I saw that you guys checked to see if the value was too low like in the code below to avoid that issue.
public void OnMove(InputAction.CallbackContext context)
{
MoveAxis = context.ReadValue<Vector2>();
if (MoveAxis.sqrMagnitude < 0.01f)
MoveAxis = Vector2.zero;
}
In the standard input system there’s a “Dead” value. This might be the reason why it’s different from your new input system.
I got my Input.GetAxis(“Horizontal”) working by using 1D Axis, just click the plus button and add 1D Axis Composit, hope this helps:
Is there any update on dampening the input value? I’m currently using v 1.0.
Hey, i find a solution for this. If anyone is still looking for. Basically if you put your “inputSystem.movement.ReadValue()” inside “Awake()” or “Start()” you will actually invoke the callback just one time when the system detects the input and never updating that value until it comes back to “input.movement.cancelled” and the player make another move so, the solution is to put your “input.movement.ReadValue()” in Update(). Then everytime it updates it will get the current updated value of the input.
Alternatively could you tell us the math equation that is used in the old Input Manager that takes sensitivity and gravity into account?
I got joystick angle using this
if (rightJoystick != new Vector2(0, 0))
{
Vector3 rotate = new Vector3(0, (-Mathf.Atan2(0 - rightJoystick.y, 0 - rightJoystick.x) * (180 / Mathf.PI)) - 90f, 0);
transform.localEulerAngles = rotate;
}
Found it here: https://answers.unity.com/questions/955123/vector2angle-returning-0-why.html?childToView=1759039#comment-1759039
Hi, I have the same problem too, I managed to change every other input in my game to the new input system, except for the movement Input.GetAxis Horizontal/Vertical. Did you manage to find a solution?
My main problem is, that all I get is digital input with the WASD keys, even if I set the control type to Analog.
With the old GetAxis, I got a smooth acceleration, it took a couple of frames to go from 0 to 1. Now its instant, and when I run in circles it looks stupid.
Even with a PS4 controller’s analog stick, the old Input.GetAxis is a 1000 times smoother, when I run around in circles with the new input system it’s really choppy. (update mode set to Dynamic Update)
see the post linked in Axis Gravity / Smoothing? and the OPs solution. What you are seeking is sensitivity (digital input get smoothly increased to its max value (of 1)) and gravity (digital input gets decreased continuously to 0 after releasing).
awesome, thank you!
How were you accessing the value in the sript. Can’t seem to figure it out. The vector version I use var v = value.Get(); but I can’t figure out how to access the values when using the 1D axis
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Migration.html#getAxis
getValue<float>()
?
I never post but I have to this time…
This is what pisses me off with Unity. I was like oh they have a new input system that looks cool on the surface and then you realize its missing some core functionality… So many systems like this get updated and then they lose some of key features. Why put something out there that doesnt even cover all what the old system could do? Because that should be goal of an update, first cover everything that the old system could do and wrap it in the new fancy system that you are developing and then add features. Yes you said its coming but why didnt you wait till you had processors with this functionality this way just puts people off…
I am also looking into replicating the “old” Input.GetAxis method using the new input system. And as other people also have written, I would love to use WASD as fallback controls, when no Xbox/PS controller is connected to the system.
I’m using a “1D Axis” for this, and I’m using the C# callbacks. One thing I noticed is that I only get the onActionTriggered callback when the state of the key CHANGES. I would love to get a callback EVERY frame the key is held down, so I can keep moving the player as long as the key is held down - or as long as the joystick is held to one of the sides.
How do I configure the new input system to give me a callback every frame?
Kind regards,
Uffe
states
"
When input is received on controls bound to an action, the action will trigger callbacks in response. These callbacks are started, performed, and canceled. […]
[…] The default behavior is that when a control is actuated (that is, moving away from its resting position), started is called and then performed. Subsequently, whenever the a control further changes value to anything other than its default value, performed will be called again. Finally, when the control moves back to its default value (i.e. resting position), canceled is called.
[…] In these callbacks, you will receive a InputAction.CallbackContext with information about how the action got triggered. For example, you can use ReadValue() to read the value from the binding that triggered or use interaction to find the interaction that is in progress.
action.started += context => Debug.Log("{context.action} started");
action.performed += context => Debug.Log(“{context.action} performed”);
action.canceled += context => Debug.Log($“{context.action} canceled”);
"
inside the Remarks at the top towards the end,