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

Locking and unlocking by ways other than input action id. #3

Open
astrochili opened this issue Sep 23, 2023 · 5 comments
Open

Locking and unlocking by ways other than input action id. #3

astrochili opened this issue Sep 23, 2023 · 5 comments

Comments

@astrochili
Copy link

astrochili commented Sep 23, 2023

From the real world, before locking the cursor, the game shows the game menu and other stages where standard behaviour is required. And then, when the player presses the "Start Game" button, the game level loads and the cursor is locked. Conversely, when the player, for example, opens a chest in the game world, the inventory window opens and the cursor is unlocked.

In this case it would be more convenient to have some kind of interface for locking, a module method or message handling. As it is not clear why locking should be related to mouse click.

Maybe I don't fully understand the idea of a virtual cursor and this is the solution?

@aglitchman
Copy link
Member

In this extension (although it's more just an example implementation rather than an extension anymore) I was assuming the behaviour of large PC games, where the game launches and you give the game cursor control with a mouse click.

That's the industrial standard in PC games, in my opinion.

As it is, I agree that this behaviour should be made customisable.

@astrochili
Copy link
Author

astrochili commented Sep 25, 2023

I realised that games really do capture the cursor always by providing their own virtual cursor.

Then, if the cursor is even virtual, usually, when you start a PC game, the cursor is captured immediately and automatically, without an additional click. To do it still need some sort of command, other than a click.

@aglitchman
Copy link
Member

To do it still need some sort of command, other than a click.

Yeah, but you can lock mouse without user iteraction only on PC/Mac. So just call window.set_mouse_lock(true) on these platforms.

P.S. I will add a flag like autolock or lock_on_click.

@astrochili
Copy link
Author

astrochili commented Sep 25, 2023

Wait a minute, it's possible to do with the inbuilt api at the moment? Omg, where have I been all this time... 😂

Thanks for the discovery! Now I'll have to figure out the best way to use it all for the operator's demo and readme 🤔

@aglitchman
Copy link
Member

Yes, there is a huge statement on the top of Pointer Lock's README:

💡 Prior to Defold 1.3.7, this extension had C API to lock/unlock mouse cursor. After the release of Defold 1.3.7, the C API was cut and since then the extension has been the demo project of how to implement mouse lock in your Defold game.

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

No branches or pull requests

2 participants