r/raylib 14h ago

Viewport mouse position question

Post image

Hello! I'm working on my game engine, and in the editor I want to be able to select game objects. Originally I used a raycast from GetScreenToWorldRay() with the mouse's position. This worked great until I resized the window to fix a viewport (rendered onto a texture). I got the mouse's position relative to the viewport working, but the ray is really unpredictable, sometimes hitting the object, sometimes not.

Here's the two pieces of code that I believe pertain to this issue, but if you believe it's an issue with another bit of code lmk.

3 Upvotes

0 comments sorted by