Skip to content

The BEST way for Unity MOBILE game testing

UNITY game MOBILE

Need to UNITY MOBILE Game testing but don’t know how? This is the tutorial for you. Learn how to test YOUR Unity game with your phone directly from the Editor!

By the way! If you are interested in becoming a professional software developer, make sure to check out our courses!

And find the video to this article here!

Get started with UNITY MOBILE game testing!

Oh hey! Don´t mind me, just playing my game on my phone..

How´d I done that? I mean, I just played it directly from the editor, that´s it…

OH! So you want me to show you how I managed to directly play my game from the editor on my phone?

Ok, can be done.

SETUP

To make this work, we will have to start by setting up the target platform, go to

File > Build Setting.

UNITY game MOBILE

There, select either IOS or Android depending on your testing device.

UNITY game MOBILE

If you haven´t yet downloaded one of the two, click on Install with Unity Hub

After installation is ready, you should be able to click on Switch Platform

Once ready, we can work on PlayerMovement Script

Let´s start with the playerMovement script, for this to work we need to use touch controls, to keep the project modular, let´s create a separate script for touch so we can swap them out at any time.

So let´s duplicate our PlayerMovement script (CTRL+D) and name it TouchPlayerMovement

Open our duplicate

OUR APPROACH

What´s our approach to accomplish this

Since we will be making a mobile game out of an FPS game, we have to think about how we can use the touchscreen for this type of games 

For the movement to work, We have separate the screen into two parts (click), one side being the camera controls, and the other, the character movement. 

As for Mobile UI, for this game, we will have a simple joystick on the left and simple buttons for jumping, sprinting, shooting and reloading, but for now, since the focus for this pair of videos is basic functionality for movement mostly for testing purposes, we will be keeping everything clean, with no UI, just knowing the two sides of our screen. Don´t worry though, we will come back to mobile UI eventually.

Let´s do that then.

IMPLEMENTATION

We will be tracking each finger separately on each side of the screen, for that, create two int variables called leftFingerID and rightFingerID

Now, in the Start method, set both to -1. We will be using that value to declare that the touch screen is not being currently touched.

Now, to divide the screen into two halves, create a float called halfScreenWidth

And in the start method,

That´ll give us the value we need, by dividing the width of the current screen in two, returning the exact value of half the screen width

Now, to actually get touches and manage it, let´s make a new void. Void GetTouchInput()

This has to be called on each frame, so make sure to call it in update

Now, we will be using Touch.touchCount to read current touches, this returns all the current touches made by the user. Let´s do something simple to test it

TESTING ON OUR PHONES

To be able to test it, download Unity Remote on the App Store, or on Google Play.

Simply open it, connect the device to PC,

Go to Edit>Project Settings and choose as Device your own device

If it doesn´t appear, you may need to restart your Unity.

Now, swap out the PC PlayerManager with the TouchPlayerManager

And press play to test it out, it should appear on your phone screen now

Great!

CONCLUSION for UNITY MOBILE game testing

As you can see, we could easily detect input from our touches on our phone, directly in our Unity Editor, and even were able to see our game as if it were already build.

From here you can keep adding more controls, more refined controllers, and add some visual buttons and such. This will serve you as a great base to start your very own mobile game.

If you want to learn more about mobile game development and game development in general, make sure to check out the course this video is from! A lot of great value awaits you there, and even get a completion certificate from it, show some proof of your advanced Unity knowledge to the world.

Enter your email and we will send you the PDF guide:
Enter your email and we will send you the PDF guide