Can I make code for PC and HTML5 in one script? (html5.set_interaction_listener)


As enthusiast, I plan to make 3D 3rd person game with 360 degrees rotared camera by mouse firstly for itch.io and later for PC and so on.
But I found that html5.set_interaction_listener breaks camera rotation for PC but works well in Google Chrome.
Can I make one script for HTML5 and PC, or I need to change script for different platforms?

Defold version: 1.8.1
Build time: 2024-06-24

You can use sys.get_sys_info() to find out if the program is running as HTML5 or not. It returns a table, you’re looking for the value of key “system_name” to find out what kind of device is running the game.

2 Likes

You can also just check if the html5 table exists:

if html5 then
…
end
3 Likes