Update not working? Or is the script bugged?

I found out that this should make the enemy follow the player. But it doesn’t update and only goes to where the player originally was

void Update()
{
transform.position = Vector3.MoveTowards(transform.position, player.transform.position, speed*Time.deltaTime);
transform.LookAt(player.transform.position);
}
There is also this as well

// Vector3 lookDirection = (player.transform.position - transform.position).normalized;
// transform.Translate(lookDirection*speed);
This also does the same thing only moves over to where the player originally was.

Have you made sure you’re referencing the player in the scene, and not perhaps the player’s prefab?

We know Update works, but you need to debug where in your code/project set up the error is.

2 Likes

Huh thank you …