I'm trying to follow the "Nightmare " tutorial of the channel by playing nils , my script does not show any error, but my character does not move and Unity 5
shows this error related to the horizontal axis. I checked the Nils video and it does not change anything in Axis
, it just shows.
So I can not move my character and it goes into the Idle animation. thanks in advance.
the error presented by Unity 5
ArgumentException: Axis horizontal input is not setup. To change the input settings use: Edit - > Project Settings - > Input PlayerMovement.FixedUpdate () (at Assets / Scripts / Player / PlayerMovement.cs: 37)
follow 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);
}
}
follows the horizontal input picture being reported in the error
I kept following the tutorial and everything is working except for the fact that I can not move and not even the mouse is followed, but now the console shows an error on line 56 that is here:
//efetua o movimento no personagem
playerRigidbody.MovePosition(transform.position + movement);