Gareth's Dev Log #4: Bringing Mobile-Friendly Gameplay to the Browser



Introduction

As we approach the finish line, I’m proud of what we’ve accomplished. While time constraints meant postponing some features, we’ve created a small but functional game that effectively showcases our original concept.

One tough decision was to delay publishing to the Google Play Store. However, I found a way to utilize our mobile-friendly controls for a browser-based gaming experience on mobile devices, ensuring players can still enjoy the game on their phones.

Goals

  • Implement a detection system to identify mobile web browsers.
  • Enable mobile controls for an optimized browser-based gaming experience.

Steps Taken to Detect If Game Is Running On Mobile

To provide a seamless experience for players using mobile browsers, I implemented a detection system that dynamically adjusts the game’s interface and controls.

1. Setting Up MobileDetection.jslib

  • I created an a Assets/Plugins folder in Unity and added a JavaScript library file named MobileDetection.jslib.
  • In this file, I wrote a script that uses JavaScript checks to detect mobile browsers.

2. Integrating MobileDetector in Unity

  • I created a new C# script named MobileDetector, which interacts with the JavaScript library to determine if the game is running on mobile.
  • The script provides an IsRunningOnMobile() method, allowing other parts of the code to query the device type.
  • I added the MobileDetector script to an empty GameObject in each level scene.

3. Adapting Gameplay for Mobile

  • Wherever device-specific adjustments were needed, I referenced the MobileDetector and its IsRunningOnMobile() method.
  • With these changes, the game now recognizes when it’s being played on a mobile browser and adjusts the interface to include the mobile controls we previously developed.

Closing Thoughts

While we couldn’t meet all our initial goals, I’m thrilled that players can still enjoy our game on mobile devices via web browsers. This workaround allows us to showcase our mobile-friendly design and keeps the game accessible to a wider audience.

Moving forward, I’d like to revisit publishing on the Google Play Store, as it remains a key milestone for Career Quest. For now, I’m proud of the progress we’ve made and the lessons learned along the way.

Leave a comment

Log in with itch.io to leave a comment.