After following the video, the enemy moves towards the original position of the player instead of where the player actually is. I’ll move the entity around and the enemy will ignore it. In fact, trying to move the enemy just causes it to move straight back towards the starting position of the player. I tried to bake the navmesh again. Where did I go wrong?
Only way i could get this to work is to have the enemy follow the player instead of something with the Player tag.
so change
player = GameObject.FindGameObjectWithTag ("Player").transform;
to
player = GameObject.Find ("Player").transform;
The line “player = GameObject.FindGameObjectWithTag (“Player”).transform;” isn’t working, check the value of player I bet it is null, hence you are moving to 0,0,0 at the line “nav.SetDestination (player.position);”.
I think you’ll find the tag “Player” is not assigned to the player object. In Unity editor, look in the Hierarchy window and click the "Player"root item, now look at the Inspector window and make sure the Tag dropdown (at the top) is set to “Player”. If you don’t have a “Player” tag in the list, do “Add Tag” and create it.