Hey there,
Using Unity 2020.2.4f1
Updated from Input System 1.0.2 to 1.1.0-preview.3 and immediately noticed that my input behaves different now.
I setup a composite binding for movement like this:
With 1.0.2 I could walk my diagonally with my character in my 2D game, with 1.1.0 I can’t anymore.
My code to process the movement right now:
public void OnMovement(InputAction.CallbackContext context)
{
//TODO: Fix Animations!
Vector2 input = context.ReadValue<Vector2>();
switch (context.phase)
{
case InputActionPhase.Started:
Log.Info("Started Move Input");
facingDirection = GetInputDirection(input);
gameEntity.SpriteAnimatable.SetAnimationState(AnimationState.WALK);
break;
case InputActionPhase.Performed:
Log.Info("Performed Move Input");
facingDirection = GetInputDirection(input);
SetPlayerDestination(input);
break;
case InputActionPhase.Canceled:
Log.Info("Canceled Move Input");
gameEntity.LastFacingDirection = facingDirection;
input = Vector2.zero;
SetPlayerDestination(input);
gameEntity.SpriteAnimatable.SetAnimationState(AnimationState.IDLE);
break;
}
}
I upgraded from 1.0.2 to 1.1.0 preview 1 and there everything was working as with 1.0.2.
Tested with 1.1.0 preview2 and there the issue happens, too, so apparently something was changed or introduced in preview2
So my questions are:
- What changed with 1.1.0? Is this maybe a bug? Do I have to specifiy something specific now in the InputAction Asset or maybe in code to make it work like in 1.0.2?
I looked into the docs and I don’t know exactly what influenced this behaviour,
was it this:
If so, I tweaked the values in the Global Settings and apparently nothing changed.
- I also have the feeling that I don’t understand how the “Canceled” Phase works.
In 1.0.2 it’s like this:
When I hit “D” and hold the key on my keyboard my character walks to the right all the way. When I release it, they stop.
When I hit “D” and hold the key and at some point hit “S” and hold it (while also holding D) on my keyboard, the input gets canceled and they stop walking. When I release the D key they walk to the left and the started/performed phases for the S-binding get processed. Now this I understand.
But this does not happen if I do the same with this:
when I start hitting and holding “D” and then also hit the “W” key, the character moves diagonally to the right, which is my personal desired behaviour, but if it would be consistent shouldn’t it cancel the input of “D”?