[SOLVED] Issue with screen-to-world coordinate

Hi,

I’m actually developing a small game for a smart screen with Windows OS.

We are testing the game with a mouse, but the mouse is not working :

  • First, when I activate Fullscreen mode in game.project, the mouse is not detected.
  • I used DefOS to fix the issue, but it still has problem. The mouse doesn’t work on certain parts of the screen / we can’t click on certain game objects. I don’t know what is causing this.

Edit : it appears that the issue is showing when the window changes size (fullscreen or maximized)

Is there a simple way to handle the mouse in fullscreen mode on Windows? Thank you in advance for your help.

What do you mean by “the mouse is not working”, exactly?

Are you toggling fullscreen using DefOS?

Sorry, I didn’t explain it well. When the game is fullscreen/maximized we can’t click on certain game objects, yet it works fine in window mode.

I’m toggling fullscreen with DefOS using defos.toggle_fullscreen(). Mouse interactions use Defold-input cursor script.

certain game objects

Sounds like you’re trying to click on game objects, not GUI nodes, right? In that case, this is probably a screen-to-world coordinate mapping issue.

When the game is normal-sized, your mouse maps to the game world perfectly. However, when you resize the window, the screen is stretched. The game objects now appear in a different position on the screen, however they retain the same world coordinates as before. The mouse coordinates do not retain the same coordinates as before.

Are you using a custom camera like rendercam? If so, it comes with handy conversion functions to solve this problem.

3 Likes

Yes, I’m making a drag-and-drop mini-game and I decided to go with game objects instead of GUI nodes.

Thank you very much for the explanation, it’s clear now. I’m not using rendercam but I will definitely check it.

1 Like

I’ll drop a recommendation for Orthographic:

I don’t think Rendercam is actively supported anymore, though of course it remains a solid camera asset and anyone is free to pick it up again should it need updates.

1 Like

Thank you :slight_smile: