Libgdx, Box2D, Box2dLight

Hello there

I have a little problem with Box2dLight. I want it to rotate to the direction where the hand is pointing (follow the mouse pointer).

So I made a little gif to show ya how it’s behaving.

As u can see, it’s pointing opposite direction :l.

So this is how I create my light:



			light = new ConeLight(ray,100, Color.WHITE, 200,arm.getPosition().x,arm.getPosition().y, 360, 20);
			light.attachToBody(arm);
			light.setColor(Color.BLUE);

 

This is how I rotate the arm:



public void rotate() {
		Vector3 worldCoords = camera.unproject(new Vector3(Gdx.input.getX(),Gdx.input.getY(), 0));
		Vector2 vec2 = new Vector2(arm.getWorldCenter().x - worldCoords.x,arm.getWorldCenter().y- worldCoords.y);
		vec2.set(vec2.x, vec2.y);
float angle = (float) Math.atan2(arm.getWorldCenter().y - worldCoords.y, arm.getWorldCenter().x - worldCoords.x);
                arm.setTransform(new Vector2(arm.getPosition().x, arm.getPosition().y), angle);
}


And this is where rotating is happening:



	public boolean mouseMoved(int screenX, int screenY) {
		
		mx = Gdx.input.getX();
		my = Gdx.input.getY();

			light.setPosition(arm.getPosition().x, arm.getPosition().y);

			System.out.println(Math.toDegrees(arm.getAngle()));

		rotate();
		
		return false;
	}


So what I want, is that the licghtcone would point always to a mouse pointer. I read that, when attaching light to a body, it will automatically rotate to bodys direction. I have tried like changig the light direction and so, but it always seems to rotate just 180 and to an opposite direction. If u have any ideas, I would be glad :).

Cheers

Tumppu