Hi guys
I’ve been looking into rotating my player sprite to face the mouse cursor and I’ve hit an issue. The rotation works but it spins out of control.
This is the first time I’ve tried doing this and quickly read some guides but I likely missed something. Below is the code i’m using for the rotation along with a gif of the problem(The other ship you see if where the mouse is):
float angle = (float) Math.atan2(Gdx.input.getY() - player.getPlayerSprite().getY(), Gdx.input.getX() - player.getPlayerSprite().getX());
angle = (float) Math.toDegrees(angle);
player.getPlayerSprite().rotate(angle);
Sorry that the gif is so small
https://i.imgflip.com/bfq2h.gif
Like I said, I’ve not done this before or actually anything with rotations so i’m still trying to learn and hopefully someone can help me out :point: