Hello, Im trying to create a top down 2D RPG style game. I have the start of the program but I can’t figure this one part out:
When I left click an enemy, the player’s sprite should recognize that the player wants to attack that enemy. The sprite will walk up to the enemy until his attack range radius touches the enemy’s hit box (collision box 2d right?). Once the player reaches that attack range, the player’s sprite should stop moving immediately and just continue attacking.
So what’s been happening is: if I left click the enemy, the player’s sprite moves on top of the enemy sprite. And engages combat this way. (While in the middle of combat) If i click and move the player’s sprite to the other side of the screen, the player automatically moves back to the enemy sprite, but this time, it stops at appropriate combat distance and continues fighting.
How do I fix this so the player sprite engages in proper combat the first time around. Thank you