I am tryna makin' a 2D game with a 3D player (kinda of Factorium). I got stuck on the rotating of the player. I'd like it look always torwards to the mouse. e.g. If I move mouse on the top-left of the window, player will rotate towards the same direction.
I read on some other question about the method below, but it doesn't work properly:
private void rotatePlayerToMouse(OrthographicCamera camera) {
Vector3 mousePos = camera.unproject(new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0));
Vector3 playerPos = this.getPosition();//this.instance.transform.getTranslation(Vector3)
float degree = (float)Math.atan2(mousePos.y - playerPos.y, mousePos.x - playerPos.x);
System.out.println(degree);
this.instance.transform.rotate(new Vector3(0f, 0f, 1f), degree);
}
This method allows player to rotate. Player rotates both direction, but it doesn't stop rotating...
What is wrong?