Hi. I've got an idea of creating a mini-shooter with a top-down perspective.
Everything went smoothly till i came to the enemy programming. I wanted the enemies to move towards the player, and i knew in theory how i am to do it. I used this piece of code in order to determine the direction at which the enemy will chase the player.
float m_angle = atan2(target.getPosition().y - enemy.getPosition().y, target.getPosition().x - enemy.getPosition().x);
sf::Vector2f direction(std::cos(m_angle), std::sin(m_angle));
enemy.move(direction * 190.f * deltatime);
I placed it into the enemy::update function- same function where the window.draw(enemy); was. Although it worked, and the enemy was chasing the player around the map, it has shown different results when i had several enemies. I made a scene where 7 enemies were supposed to chase the player. And they did, in fact. However, while running towards him, the enemies all took the same position and were like in each other. So instead of 7 circles chasing my player, i saw 1 circle that included all those 7( screenshots provided ).
As it can be seen at screenshot 1, in the beginning, all seven circles are separate. However, after a short chase, they come to the same position and start moving synchronically. How do i make it look like a normal chase, without my circles coming into one-another(keep distance)?
Thanks in advance.