How to write a 3D game for Android using Unreal Engine: Part 1
There are many ways to develop games for Android, and one of the best ways for 3D development is to use an engine. An engine provides the essentials to make 3D meshes from 2D images, physics, realistic lighting and many more features that would otherwise be very time consuming for a developer to program from scratch. So welcome to part 1 in how to make a first person shooter in Unreal Engine. Let’s get started.
What is Unreal Engine?
Setting up Unreal Engine for Android development
Setting up Unreal Engine for Android is an actually pretty easy step and while Unreal Engine does not natively come with Android support, you just have to run “Android Works” found in the Engine > Extras > Android folder on your computer. The easiest way to find “Android Works” is to just do a search in your filesystem.
If you are running OS X be sure to install Java 6 from here and Java 7 from here. Unreal recommends uninstalling any other version of the Android SDK to ensure Unreal Engine is using the correct one, and while I recommend this if you are exclusively going to use Unreal Engine for Android development, I have had no issues with having at least 3 Android SDKs on my computer including one for Android Studio and one for Unreal Engine. Make sure Unreal Engine and the launcher are closed while installing Game Works. While installing accept all of the licenses and that’s all you need to do, everything is automated. Unreal also has a detailed step-by-step guide for installing Android Works, but it should only really be needed for troubleshooting, the process is fairly simple.
Getting the base game set up
Unreal Engine makes it very easy to get a first person shooter prototype made. I will be using version 4.11.2, as it is 100% compatible with the sample projects provided by Unreal. Just go to File > New Project. Once there, make sure the blueprint tab is selected and click “First Person”, select mobile/tablet from the drop down where it says desktop and make sure maximum quality is selected right beside it. Create the project and a basic scene will load. It is also a great idea to download Unreal’s sample projects from the “Learn” tab in the Epic Games Launcher. For this article, I will be taking different elements from these samples along with ones I have created myself to make a scene. With this base game set up, you will be able to move the player via mouse and keyboard on the desktop or use the on screen joysticks to move and a tap on the screen to fire. There will be more details on this in part 2 when we refine the controls to be more user friendly.
How to use Unreal Engine
Now that you have the game open and ready to develop for, it is important to understand the user interface and what each element does. In part 2 of this tutorial, more detail will be given on specific types of assets including meshes, materials, blueprints and textures, along with others. Let’s get started with the user interface.
- Starting with the green highlighted section: This is the main toolbar you will be interacting with when you want to build and test your app. From here you will be able to select the application settings in “Settings”, build the project, which makes sure all of the lighting and the like are correct in “Build”. You can also play the app on your computer in a selected viewport (which is just like playing the game), run the game and have a free camera or even launch the game on your Android device using “Launch”. All of these buttons on the toolbar have drop downs with various options. The good news is Unreal Engine tells you what each option does when you hover the mouse over it, so they are pretty self explanatory.
- Red section: This is where you will be able to place certain types of objects in the scene, they are broken into categories on the left just by the red highlighted area. These objects can include basic shapes, particle effects, cameras, lighting and much more. Once again, Unreal Engine tells you the location and a description of each instance if you hover your mouse over it.
- Blue Section: This is every single thing in your scene, including lighting, particles, objects and everything else. In this area you can select what you want to modify its properties in the pink section, which we will get into next, as well as hide and lock the instance if you so choose.
- Pink Section: This is one of the most important sections, as this will give you all of the control over an object. For example, in the scene above you can see the Android Authority logo I made in Photoshop and Blender. As you can see, it is green, just like the 2D logo. When I imported the .obj file into Unreal Engine, the logo was a light gray. To change this I selected a green material in the pink section that I made and applied it to the object. When an object is selected, all of the default options, including materials, will show up here. You also have the ability to add a component to the object, like point lighting, skeletal meshes and blueprints. Unreal has a detailed guide to components.
- Orange section: This is where all of your assets for your project will be, this includes everything under the moon that is in your project folder. From here you can import more assets using the handy import button in green as well as the ability to drag and drop stuff onto your scene. It is a very good idea to be as organized as possible so you know where everything is, but if you are disorganized, like me, there is a search bar to save the day.
It will take a little bit of time to get used to the user interface if you are coming from say, Unity, but the UI is very intuitive once you get used to it.
Adding assets to your scene
Arguably the most important part of making a game is setting up the scene. While the base game with a basic scene is already set up at this point, there is a likely chance that you want to add more onto the scene in the form of walls, objects and anything else. To do this, focus on the orange and blue sections of the user interface. In the orange section you can browse all of your content in the project and with a simple drag and drop, place it in the scene.
Once the asset is added, you will see a 3 dimensional axis on the object you just dragged in. This will allow for the asset to be moved along all 3 axes with ease, but not too much precision. To move assets more precisely, focus your attention to the blue area of the user interface. There you will see a “Transform” section. Here you will find “Location”, “Rotation” and “Scale”. Allowing you to move the asset in 3D space, rotate the asset along any axis and scale make the asset bigger or smaller respectively. Using this method, you can create floors, walls and anything else imaginable.
By default you will get a basic white material if you made the asset yourself and did not make a material to go with it. To change the material you can go under the “Material” section and change it there by clicking the default material applied and search for a different one and selecting it. This is everything you need to create a basic wall or the like, we will go into more detail in part 2 when we cover ground wetness and reflections shown in the above image.
Wrapping up part 1
You should now have a simple, but working, first person shooter for Android, along with a basic understanding of Unreal Engine 4. In part 2, we will dive deeper into each component of the UI as well as making the game a lot better with a bigger level, prettier scenery and even artificial intelligence in the form of enemies. Stay tuned to Android Authority for part 2 and if you have any questions or comments be sure to let us know in the comments below!