Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera.ToWorld returns wrong result. #3

Open
DiaDeTedio opened this issue Jul 13, 2018 · 2 comments
Open

Camera.ToWorld returns wrong result. #3

DiaDeTedio opened this issue Jul 13, 2018 · 2 comments

Comments

@DiaDeTedio
Copy link

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
Copy link

sorends commented Aug 3, 2018

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants