Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move input stop working and gets working again if i press another input #677

Closed
anynoise00 opened this issue Jun 13, 2019 · 6 comments
Closed
Labels

Comments

@anynoise00
Copy link

anynoise00 commented Jun 13, 2019

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

@anynoise00 anynoise00 changed the title input stop working move input stop working and gets working again if i press another input Jun 13, 2019
@anynoise00 anynoise00 reopened this Jun 13, 2019
@SKroell
Copy link

SKroell commented Jun 15, 2019

Same issue as #663

@JiaUnity
Copy link
Contributor

JiaUnity commented Jun 20, 2019

I still cannot repro this.
@anynoise00 Any chance you upload a minimal repro project, or just the InputActionAsset used for this script?

@anynoise00
Copy link
Author

sorry for the late answer, i'll do it tomorrow, i'm not home right now.

@anynoise00
Copy link
Author

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.

@JiaUnity
Copy link
Contributor

JiaUnity commented Jul 2, 2019

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.
Settings
Please let me know if this solve the issue or the bug still repros.

@stefanunity
Copy link
Collaborator

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants