My navmeshagent simply doesn’t move in the y-axis when I try to move it. The goal of this script is to create a (non-realistic) effect of the collision. AddForce doen’t work as well as it only seems to be impacted in the x and z axis. I know the rest of the script works because the agent pauses when it gets hit.
private Rigidbody rb;
void Start ()
{
rb = GetComponent<Rigidbody> ();
}
void OnCollisionEnter (Collision other)
{
if(other.gameObject.CompareTag("Wrecking Ball"))
{
GetComponent<NavMeshAgent> ().Stop ();
transform.Translate (-1, 5, 0);
Invoke ("Resume", 2.0f);
}
}
void Resume()
{
GetComponent<NavMeshAgent> ().Resume ();
transform.Rotate (-random, 0, 0);
}