I'm following Nightmares step by step on Unity3D, but following the Nils tutorials I came across a problem, after finishing the script the character does not move on the test screen, he stands still in the Idle animation, and she does not continue, only loads 1 time. Thanks for the help, big hug!
usingUnityEngine;publicclassPlayerMovement:MonoBehaviour{publicfloatspeed=6f;//VelocidadedojogadorVector3movement;//VetorresponsavelpelomovimentoAnimatoranim;//ResponsavelpelatransiçaodaanimaçaoRigidbodyplayerRigidbody;//ResponsavelpelafisicadoobjetointfloorMask;//MascaradechaofloatcamRayLenght=100f;//InformaçoesparaoraycastvoidAwake(){//Atribuiramascaradacamada.floorMask=LayerMask.GetMask("Floor");
//Atribuir as referencias.
anim = GetComponent <Animator> ();
playerRigidbody = GetComponent <Rigidbody> ();
}
void FixedUpadate()
{
float h = Input.GetAxisRaw ("Horizontal");
float v = Input.GetAxisRaw ("Vertical");
Move(h,v);
turning();
Animating(h,v);
}
//Movimenta o jogador
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);
}
//Gira 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);
}
}