Argumentexcept Unity5 Input error horizontal is not setup

Asked

Viewed 194 times

1

I’m trying to follow the game tutorial "Nightmare" canal playing with Nils, my script does not present any errors, however my character does not move and the Unity 5 shows this error related to Axis horizontal. I checked the Nils video and it does not change anything on Axis, only shows. So I can’t move my character and he goes into Idle animation. I thank you in advance. follows below the error presented by Unity 5

Argumentexception: Input Axis horizontal is not setup. To change the input Settings use: Edit -> Project Settings -> Input Playermovement.Fixedupdate () (at Assets/Scripts/Player/Playermovement.Cs:37)

follows the code PlayerMovement.cs

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    //velocidade do jogador
    public float speed = 6f;

    //vetor responspável pelo movimento
    Vector3 movement;          

    //responsável pela animação              
    Animator anim; 

    //responsável pela física do objeto
    Rigidbody playerRigidbody;

    //máscara de chão
    int floorMask;

    //inf para o Raycast
    float camRayLenght = 100f;


        void awake()
    {
        //atribuir a máscara da camada
        floorMask = LayerMask.GetMask("Floor");

        //atribuir as referências
        anim = GetComponent<Animator>();
        playerRigidbody = GetComponent<Rigidbody>();
    }


    void FixedUpdate()
    {
        float h = Input.GetAxisRaw("horizontal");
        float v = Input.GetAxisRaw("vertical");

        Move(h, v);
        Turning();
        Animating(h, v);
    }



    void Move(float h, float v)
    {
        //determina o movimento
        movement.Set(h, 0f, v);

        //normaliza o movimento
        movement = movement.normalized * speed * Time.deltaTime;

        //efetua o movimento no personagem
        playerRigidbody.MovePosition(transform.position + movement);
    }

    //girar o jogador  
    void Turning()
    {
        Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);

        RaycastHit floorHit;

        if (Physics.Raycast(camRay,out floorHit, camRayLenght, floorMask))
        {
            Vector3 playerToMouse = floorHit.point - transform.position;
            playerToMouse.y = 0f;
            Quaternion newRotation = Quaternion.LookRotation(playerToMouse);
            playerRigidbody.MoveRotation(newRotation);

        }

    }
    void Animating(float h, float v)
    {
        bool walking = (h != 0f || v != 0f);
        anim.SetBool("IsWalking", walking);

    }


}

Follow Horizontal input photo being reported in errorinserir a descrição da imagem aqui

I kept following the tutorial and everything is working except for the fact that I can not move and the mouse is not followed, but now the console shows an error in line 56 that is this here:

    //efetua o movimento no personagem
    playerRigidbody.MovePosition(transform.position + movement);
  • 1

    Post the Playermovement.Cs code

  • I just posted the code next to the question

  • Tried to put Horizontal and Vertical with the first letter uppercase?

  • no, but I’ll try even though I don’t think this one in quotes would change.

  • You’re damn right it changes kk

  • It hasn’t changed at all like I thought.

  • Go to the Edit tab -> Project Settings -> Input, you will see the game controls, note that there is Horizontal and Vertical (so capital letters are important) check if they are correct, with Axis X and Y

  • Here in my Unity 5 worked perfectly, for sure are your inputs that are set wrong.

  • I will post photos my input but I have already reset once until in case they are wrong and nothing and in the video nil does not change anything in Axis only shows that there Voce can configure the controls of the game

  • ready there is.

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.