2D Enemy doesn't chase the player anymore

Hi peeps,

So I’ve set up a scene after following Brackey’s “How to make a 2D platformer,” but after the last video I noticed that the enemy (AlienSpaceShip) doesn’t chase the the player. I suspect that the enemy, which is now a prefab, doesn’t chase the player that’s in the game, but rather the player prefab which has a static position.

Here is what I mean:

See how AsterPathfinding makes the enemy follow a line to the static position of the player prefab(which is hidden), instead of the player next to it?

The problem might be that the prefab is selected in the dropdown menu of the enemy instead of the actual player. Or maybe even the Astarpathfinding system that is messing with it.

Any ideas?

Kind Regards,


You need to assign the actual player instance as the target. Prefabs in Unity are also GameObjects and have their own positions (even though their positions usually are not very useful). Think about if you had 2 player instances and you referenced the prefab. How would it know which of the two player instances to move to.

1 Like

Dear Aron,

Thank you for your reply. I understand your suggestion, but I have no idea how to assign the player to the enemy’s settings as long as Unity won’t let me add game object from the scene to the prefabs.

You would have to do it from a script. For example when the enemies are instantiated in the world.

1 Like

Alright you got me haha. Apparently I forgot tutorial 15 of the course where I indeed am supposed to create a C# script with a couple of handler using IEnumerators. I’m fixing it now, thanks for your time.