Comora icon indicating copy to clipboard operation
Comora copied to clipboard

Camera.ToWorld returns wrong result.

Open DiaDeTedio opened this issue 7 years ago • 2 comments

I make a Vector2(0,0), and if I render a sprite in this position, the sprite will rendered at center of screen, but, if I use camera.ToWorld with mouse position, it return the wrong value.

DiaDeTedio avatar Jul 13 '18 23:07 DiaDeTedio

I have the same problem. Camera.ViewportOffset.ToAbsolutePosition seems to work fine though. Haven't tested with zoom and rotation, since i don't need it, so it might not work there.

sorends avatar Aug 03 '18 09:08 sorends

I found a solution that seems to work fine afterwards, just use the code below, for me it worked: var mstate = Mouse.GetState(); Vector2 mpos = new Vector2(mstate.X, mstate.Y); mpos = Vector2.Transform(position, camera.ViewportOffset.Absolute); It seems that ToWorld returns the argument plus the position of the camera.

DiaDeTedio avatar Aug 04 '18 23:08 DiaDeTedio