So im making a 2d shooter game where enemies come at you and you shoot them ad they should follow you trying to kill you. I use a simple Vector2.MoveTowards to make them follow you (heres that code: //Moves enemy to player
transform.position = Vector2.MoveTowards(this.transform.position, player.transform.position, speed * Time.deltaTime);). Obviously i made the enemy a prefab so i can spawn them in waves. But when i put them as a prefab they no longer have a reference to the player. So i had to make the player a prefab (because the simple gameobject in the hierarchy didn’t work) but then when i start the game the enemy moves to the position the player was at the START of the game. It doesn’t update where it should follow. When i don’t use the prefab (of the enemy) it works fine. Pls help. And if you want the player and enemy script just ask.
Did you try and use Tags to find the player?
Yes that doesn’t work
Actually i did do gameobject.find and it worked