I have an enemy in my game that is supposed to move left and right unless the player is close enough. If the player is close enough, it shoots a bullet at the player. I have the code for it, and it works.
Except for one part. The enemy always just shoots the bullet, no matter the distance between the player and the enemy.
I have tried using the distance(x1, y1, x2, y2), but I might be using it incorrectly.
Please help me understand how to use the distance tool correctly in the code, or if there is another way that works better.
Thanks!