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 error
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);
Post the Playermovement.Cs code
– Leonardo
I just posted the code next to the question
– Matheus Abner
Tried to put Horizontal and Vertical with the first letter uppercase?
– Leonardo
no, but I’ll try even though I don’t think this one in quotes would change.
– Matheus Abner
You’re damn right it changes kk
– Leonardo
It hasn’t changed at all like I thought.
– Matheus Abner
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
– Leonardo
Here in my Unity 5 worked perfectly, for sure are your inputs that are set wrong.
– Leonardo
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
– Matheus Abner
ready there is.
– Matheus Abner