Boa tarde o console do meu Unity esta me me retornando esse erro porém não consigo solucionar:
MissingComponentException: There is no 'Animator' attached to the "UpperLeg_Right_jnt" game object, but a script is trying to access it. You probably need to add a Animator to the game object "UpperLeg_Right_jnt". Or your script needs to check if the component is attached before using it. UnityEngine.Animator.SetBool (System.String name, System.Boolean value) (at :0) ControlaJogador.Update () (at Assets/ControlaJogador.cs:37).
segue o código de referencia
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class ControlaJogador : MonoBehaviour {
public float Velocidade = 10;
private Vector3 direcao;
public LayerMask MascaraChao;
public GameObject TextoGameOver;
public bool Vivo = true;
private Rigidbody rigidbodyJogador;
private Animator animatorJogador;
private void Start()
{
Time.timeScale = 1;
rigidbodyJogador = GetComponent<Rigidbody>();
animatorJogador = GetComponent<Animator>();
}
// Update is called once per frame
void Update () {
float eixoX = Input.GetAxis("Horizontal");
float eixoZ = Input.GetAxis("Vertical");
direcao = new Vector3(eixoX, 0, eixoZ);
if(direcao != Vector3.zero)
{
animatorJogador.SetBool("movendo", true);
}
else
{
animatorJogador.SetBool("movendo", false);
}
if(Vivo == false)
{
if(Input.GetButtonDown("Fire1"))
{
SceneManager.LoadScene("meujogo");
}
}
}
void FixedUpdate()
{
rigidbodyJogador.MovePosition
(rigidbodyJogador.position +
(direcao * Velocidade * Time.deltaTime));
Ray raio = Camera.main.ScreenPointToRay(Input.mousePosition);
Debug.DrawRay(raio.origin, raio.direction * 100, Color.red);
RaycastHit impacto;
if(Physics.Raycast(raio, out impacto, 100, MascaraChao))
{
Vector3 posicaoMiraJogador = impacto.point - transform.position;
posicaoMiraJogador.y = transform.position.y;
Quaternion novaRotacao = Quaternion.LookRotation(posicaoMiraJogador);
rigidbodyJogador.MoveRotation(novaRotacao);
}
}
}