To get the enemy to move away from the player, when we set the enemy’s velocity, just change it to “* -SPEED”. Changing it to negative reverses the direction. Then you’ll want to do something that stops them from running off screen instantly. One way to do this is to check the distance to the player in the enemy script. If the player is far away, set velocity to zero. It might even be fun to have them move slowly towards the player.
the goat with a tutorial
Nice tutorial as always!
How to make the enemies avoid the player
To get the enemy to move away from the player, when we set the enemy’s velocity, just change it to “* -SPEED”. Changing it to negative reverses the direction.
Then you’ll want to do something that stops them from running off screen instantly. One way to do this is to check the distance to the player in the enemy script. If the player is far away, set velocity to zero. It might even be fun to have them move slowly towards the player.
Nice tutorial as always!