Null Object Error

So I'm using the (x,y) position of the player and the enemy to set the angle so the enemy can follow the player. Everything goes well until I kill the enemy. When the player or the enemy dies the game crashes and I get the null object error. I have added the condition "if player and enemy is alive" but it haven't solved the problem. I can't understand why I keep getting this error.
I will attach the game archive if someone wants to look.


  • Posts: 40
Your code is wrong

It works fine, the enemy follow the player if the distance is too large, and stop when it get closer.