Logo que conclui a parte de fazer os zumbis pararem quando ficam a uma distancia < 2 do jogador esse erro comecou a aparecer:
O texto completo que aparece é:
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Graphs.Edge.WakeUp () (at <00578d709e2b43b38413b2b2b34f6fbe>:0)
UnityEditor.Graphs.Graph.DoWakeUpEdges (System.Collections.Generic.List1[T] inEdges, System.Collections.Generic.List
1[T] ok, System.Collections.Generic.List`1[T] error, System.Boolean inEdgesUsedToBeValid) (at <00578d709e2b43b38413b2b2b34f6fbe>:0)
UnityEditor.Graphs.Graph.WakeUpEdges (System.Boolean clearSlotEdges) (at <00578d709e2b43b38413b2b2b34f6fbe>:0)
UnityEditor.Graphs.Graph.WakeUp (System.Boolean force) (at <00578d709e2b43b38413b2b2b34f6fbe>:0)
UnityEditor.Graphs.Graph.WakeUp () (at <00578d709e2b43b38413b2b2b34f6fbe>:0)
UnityEditor.Graphs.Graph.OnEnable () (at <00578d709e2b43b38413b2b2b34f6fbe>:0)
Meu código:
public class ControlaZumbi : MonoBehaviour
{
public GameObject Jogador;
public float Velocidade = 5;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void FixedUpdate()
{
float distancia = Vector3.Distance(transform.position, Jogador.transform.position);
if(distancia > 2.5)
{
Vector3 direcao = Jogador.transform.position - transform.position;
GetComponent<Rigidbody>().MovePosition
(GetComponent<Rigidbody>().position +
direcao.normalized * Velocidade * Time.deltaTime);
Quaternion novaRotacao = Quaternion.LookRotation(direcao);
GetComponent<Rigidbody>().MoveRotation(novaRotacao);
}
}
}