How to know the platform that runs the game?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By M77mdsD

I want to know the platform that is running my game, but I want to even know that in HTML5. I mean I want to know if this HTML5 is running on a pc or on a phone.

1 Like
:bust_in_silhouette: Reply From: xAkuma69

similar question that would help:

https://forum.godotengine.org/6374/how-to-get-current-platform-os

:bust_in_silhouette: Reply From: Rodeo

Class OS has a method get_name() which returns a string identifying the current platform. However, it counts HTML5 as a platform, so this won’t work for your use case.

Instead you could use get_model_name(). It returns the model name on Android and iOS, but returns “GenericDevice” on unsupported (i.e. PC) platforms.

This is an old convo, obviously. But I ended up here while trying to find an answer. So, in case you’re stuck, too, here ya go!

And the code that worked for me:

var scale_factor = 1.0
if OS.has_feature("web_android") or OS.has_feature("web_ios"):
		scale_factor = 2.0
$CenterContainer.set_scale(Vector2(scale_factor, scale_factor))