Accelerometer events in HTML Application

Is there a way to get accelerometer data on HTML5 Application? I can get it through on_input method on Android build, but when i try to get it through browsers on my mobile device it returns nil… Or if not is there any way to access data from window “devicemotion” event listener or something similar?

Accelerometer data is currently only available on Android and iOS builds if I recall correctly. Are you planning to run a Defold HTML5 export on a mobile device?

Thanks for the reply :slight_smile: The plan is to have html5 browser game and if the game is opened on mobile device browser it should have access to accelerometer…

I see. What kind of game is it? Depending on the game and the hardware it is running on you shouldn’t really expect brilliant performance from an HTML5 build of the game when tested on a mobile or tablet. The Defold HTML5 builds can be expected to perform well on standard PC hardware on a modern browser though. I would recommend that you detect if the user is trying your game from a mobile browser and in that case redirect them to the relevant app store.

1 Like

Ok, i hoped that it can be achieved but you’re right performance may not be so great. I will do apps for mobile devices. Thanks :slight_smile:

1 Like

@britzl is this still your perspective on the use of the accelerometer on HTML5 builds of Defold games?

No, a lot has changed since that post was made in 2017. Defold has become faster, and so has the phones people have. Defold works really well on mobile phones in 2020.

@britzl
Hi,

Does the accelerometer support HTML5 now?
If it is support where can I find more detail or examples?

Thank you.

No, it is not something we have focused on.