Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Feature requests and bug reports
FPS camera movement not working in webgl - v6

bigcatrik
Registered User
Quote
2018-07-13 23:15:04

SOLVED: See next post.

It seems to be intermittent.

Sometimes keyboard keys move the camera and sometimes they don't. Reloading the page sometimes makes it work but more often than not doesn't.
https://bigcatrik.itch.io/coppercube-terrain-fpnos

It works in Firefox from a local drive and in Chrome with a local web server.

What could be causing this?


bigcatrik
Registered User
Quote
2018-07-14 03:12:38

SOLUTION:

Googling "itch.io keyboard not working in webgl" revealed that this isn't a problem unique to itch.io or CopperCube. The link below provided the answer. Put this code in the game's html file right after the <body> tag:

<script>
window. = function(){
window.focus();
}

window. = function(){
window.focus();
}
</script>

... and the keyboard is focused when the mouse clicks on it.

Here's the link:
https://www.reddit.com/r/gamedev/comments/39shqa/itchio_and_unity3d_webgl/


Niko, is there a reason not to add that code by default, or have a "Game Portal Compatibility" check box in the webgl export options that would add it if selected?


niko
Moderator
Quote
2018-07-16 08:36:07

It's more a problem of how the website works in which you publish your app. It looks like itch uses an iframe for this, and this is causing this. In other cases, the window.focus() might cause other side effects, so it is not a good idea to put code like this always in there.


srfstudio
Registered User
Quote
2018-08-08 20:20:59

Just to add my solution if someone is planning to publish a game on Newgrounds and wants to expend functionality to mouse entering the window & mouse leaving the window:
<script type='text/javascript'>
document.on*click = function() {window.focus();};
document.on*mouseover = function() {window.focus();};
document.on*mouseout = function() {window.focus();};
</script>
...just delete the * from code, the reply-form kept removing mouse events from post :D

This is the link to my test-room on NG if someone want to see functionality in action:
https://www.newgrounds.com/proje...

...I was hoping to figure out the solution that's more automatic but the events like On Load or Ready State didn't work :)


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internat?onal" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact