move input stop working and gets working again if i press another input
I'm new to programming and i'm using this new input system, i'm creating a simple player movimentation system for a platform game. I did the code below
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class Player : MonoBehaviour, InputMaster.IPlayerActions
{
[SerializeField] float moveSpeed = 7f;
[SerializeField] float jumpValue = 6f;
Rigidbody2D rb;
InputMaster controls;
Vector2 moveInput;
private void Awake()
{
controls = new InputMaster();
controls.Player.SetCallbacks(this);
}
private void OnEnable()
{
controls.Player.Enable();
}
private void OnDisable()
{
controls.Player.Disable();
}
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
private void FixedUpdate()
{
Move();
}
private void Move()
{
rb.velocity = new Vector2(moveInput.x * moveSpeed / 0.02f * Time.deltaTime, rb.velocity.y);
}
private void Jump()
{
rb.velocity = transform.up * jumpValue;
}
//inputs
public void OnMove(InputAction.CallbackContext context)
{
moveInput = new Vector2(context.ReadValue<float>(), 0f);
}
public void OnJump(InputAction.CallbackContext context)
{
Jump();
}
public void OnCrouch(InputAction.CallbackContext context)
{
Debug.Log("We want to crouch!");
}
public void OnInteract(InputAction.CallbackContext context)
{
Debug.Log("We want to interact!");
}
public void OnAttack(InputAction.CallbackContext context)
{
Debug.Log("We want to attack!");
}
public void OnLook(InputAction.CallbackContext context)
{
Debug.Log("looking");
}
}
but when testing it, i noticed that if i kept pressing buttons to move left and right, it sometimes stop, even if i'm with the A or D key pressed(let's say that the input system is paused). I can get my player moving again if i release the key and then press it again, or striking another input key, it's like it unpause the input system.
PS: i'm using 1D axis and keyboard to move
And sorry for my bad english, i don't know if someone will understand what i wrote
Same issue as #663
I still cannot repro this. @anynoise00 Any chance you upload a minimal repro project, or just the InputActionAsset used for this script?
sorry for the late answer, i'll do it tomorrow, i'm not home right now.
There it is https://drive.google.com/file/d/1yUYSb6hwEPDbag-GMEgwO9_al7u0Vg_k/view?usp=sharing If you keep moving from one red square to the other, changing directions, you will realize that at one moment the input will not work and you will stop even if holding the key.
Not sure if this would solve the issue, but in the Properties setting for the 1D axis, there is an option Which Side Wins.
Basically, the default is neither, so when you press both a and d down, neither side is registered.
Please let me know if this solve the issue or the bug still repros.
Hello,
we're going to close all the github issues and will concentrate bug information in the Unity public issue tracker https://issuetracker.unity3d.com/product/unity/issues?project=116&status=1&unity_version=&view=hottest.
If you are still experienceing this issue in the latest package version please do file a bug report as described here https://unity3d.com/unity/qa/bug-reporting For general feedback and discussions you can go to https://forum.unity.com/forums/new-input-system.103/
Thank you!