I brought in the Zombunny assets available for the tutorial and applied the Enemy Movement script supplied with it. When I play my game the Zombunny doesn’t follow the player position, but instead walks in place. If I declare a public variable and give the Zombunny a destination of say a mesh in the scene, he will move to that location.
Only the Y position is locked in the Zombunny rigid body.
I bet it’s something super simple I missed but I can’t find any leads and I’m kinda lost.
This is what the script looks like by the 4th tutorial video:
using UnityEngine;
using System.Collections;
public class EnemyMovement : MonoBehaviour
{
Transform player;
//PlayerHealth playerHealth;
//EnemyHealth enemyHealth;
NavMeshAgent nav;
void Awake ()
{
player = GameObject.FindGameObjectWithTag ("Player").transform;
//playerHealth = player.GetComponent <PlayerHealth> ();
//enemyHealth = GetComponent <EnemyHealth> ();
nav = GetComponent <NavMeshAgent> ();
}
void Update ()
{
//if(enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0)
//{
nav.SetDestination (player.position);
//}
//else
//{
// nav.enabled = false;
//}
}
}