How to convert mouse position to screen coordinates in 2D? (Camera 2D zoom)

inspired_coderinspired_coder Posts: 6Member

I move sprite around the screen by mouse using this code:


But, sprite position and mouse cursor is different (very). They becomes absolutely different while changing camera 2d zoom.

In 2.1 version i am used without any problems following code:


In 3.0 this code not working. Any ideas?



  • SolarLuneSolarLune Posts: 35Member
    Answer ✓

    The code's not working in 3.0 because the API must have changed. There's underscores between each word in those calls, though, both for 2.1 and 3.0?

    As for your question, you could try multiplying the mouse position by the zoom value, though you might want to normalize that position to a range (like 0 to 1) to make it easier to work with.

Sign In or Register to comment.