I want to make my player sprite to rotate towards mouse position, but the world y-axis starts from bottom and the mouse postiitons y-axis starts from the top. I could flip the y-axis from the camera with camera.setToOrtho(false); I’ve heard that you can also use camera.unproject when calculating the rotation.
Here is my player rotation method
public void rotateToMousePosition(Vector2 playerPos,Vector2 targetPos, OrthographicCamera camera){
camera.unproject(new Vector3(targetPos, 0));
float deltaX = playerPos.x - targetPos.x;
float deltaY = playerPos.y - targetPos.y;
float degrees = MathUtils.atan2(deltaX, deltaY) * MathUtils.radiansToDegrees; //calculating rotation
this.setRotation(degrees);
}
However this does not solve the y-axis problem. mouse.getY() y-axis still starts from the top. I’m doing somethong wrong?