SFML community forums

Help => General => Topic started by: AdrianHEY on April 15, 2021, 07:50:46 pm

Title: Make an object spin to face another one
Post by: AdrianHEY on April 15, 2021, 07:50:46 pm
I am trying to make the enemies face the player and I dont know what to do. I've tried this code but it didn't work:
 
void enemyRotatePlayer(sf::Sprite player) {
                float angle = atan2(player.getPosition().y - enemy.getPosition().y, player.getPosition().x - enemy.getPosition().x) * 180 / 3.141;
                enemy.setRotation(angle);
        }
Title: Re: Make an object spin to face another one
Post by: Stauricus on April 15, 2021, 10:28:39 pm
'it didn't work' means it didn't compile?