Accidental mobile compatibility


This one time my playtester demanded mobile support

​Hey all!

It has been a funny week. I had to take a week off work since daycare was closed, and came to the realization that my evening development was way more fructuous when I spent the day playing tag instead of coding for 8 hours. WHO WOULD’VE THOUGHT?!

Anyway, this is the tale of how I set up to make a PC game, but had a friend playtest the game and demand it was available for mobile. The migration from PC to mobile actually ended up being way easier than expected. I just wanted to share a few of the things I learned along the way.

Note: I use Unity and most of these tips are directly linked Unity.

Decouple your controls as much as possible

I am a huge fan of using ScriptableObjects (as seen in this Unity Writeup. I use these to hook events directly on my controls, and get my objects to listen to such events. By doing so, you eliminate all unnecessary hard links from your scene and gain the flexibility to switch listeners in and out depending on your platform.

Making seperate UIs can save you headaches

I tried making a good menu for both PC and Mobile. Never again. Fingers are not mouse cursors and should not be treated as such. Mobile screens are small and should be treated as such. There is a bit of duplicate UI work to do, but, not to sound like a broken record, if you use ScriptableObjects to refer to your variables in your UI, it becomes easy to switch in and out.

This simple yet fantastic piece of code

namespace Xltd.Utility
{
    class PlatformSpecific : MonoBehaviour
    {
        enum Platform
        {
            Pc,
            Mobile
        }

        [SerializeField] Platform platform;

        void OnEnable()
        {
            if(platform == Platform.Mobile && !Application.isMobilePlatform)
            {
                Destroy(gameObject);
            }
            else if(platform == Platform.Pc && Application.isMobilePlatform)
            {
                Destroy(gameObject);
            }
        }
    }
}

By using this component as a tag on your GameObject, you can quickly remove unwanted elements from a scene depending on the platform.

Note: We also can just disable the object instead.

What does this mean for AMazeD?

Basically, it means that when I release in the coming weeks, if you buy from itch, you’ll get access to both PC and Android with your purchase. This was not planned at first so the controls might a bit rougher for mobile, but they should sort themselves out pretty quick. Swipe controls did not cut it, virtual joystick takes a bit of getting used to but allows for the quick movements required, and I have not looked into a virtual D-Pad yet. Chances are you’ll have the choice between the two.

Get Stoink: Extreme QA

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.