Camera.ToWorld returns wrong result.
DiaDeTedio opened this issue · 2 comments
DiaDeTedio commented
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.
sorends commented
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.
DiaDeTedio commented
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.