Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit)

Personally, i do some change in the code but it’s working :
Original

    public void OnMovement(InputAction.CallbackContext context)
    {
        //This is called when you input a direction on a valid input type, such as arrow keys or analogue stick
        //The value will read -1 when pressing left, 0 when idle, and 1 when pressing right.

        if (moveLimit.characterCanMove)
        {
            directionX = context.ReadValue<float>();
        }
    }

My modified version

    public void OnMovement()
    {
        //This is called when you input a direction on a valid input type, such as arrow keys or analogue stick
        //The value will read -1 when pressing left, 0 when idle, and 1 when pressing right.
        directionX = UnityEngine.Input.GetAxis("Horizontal");
        directionX = directionX != 0 ? directionX / Mathf.Abs(directionX) : 0; //Set the var at 1 if > 0, -1 if < 0;
    }

private void Update()
{
    OnMovement();
    ...

Maybe there’s a better/simpler way, but this work so you can try it

Thanks so much!