Doran | Unity 2022 Mobile Game Development | E-Book | sack.de
E-Book

E-Book, Englisch, 480 Seiten

Doran Unity 2022 Mobile Game Development

Build and publish engaging games for Android and iOS
3. Auflage 2023
ISBN: 978-1-80461-994-0
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection

Build and publish engaging games for Android and iOS

E-Book, Englisch, 480 Seiten

ISBN: 978-1-80461-994-0
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection



Unity is a well-established player in the mobile game development sphere, and its new release, Unity 2022, is packed with new, exciting features. In Unity 2022 Mobile Game Development, Third Edition, you'll get to grips with the Unity game engine by building a mobile game and publishing it on the most popular mobile app stores as well as exploring the all-new features.
This book provides a comprehensive and practical approach to mobile game development, helping you build an endless runner game. Starting with setting up a simple Unity project for mobile development, you'll delve into various essential aspects needed to successfully create and publish your game. You'll acquire a range of skills, such as incorporating touch gestures, monetizing your game with Unity Ads and in-app purchases, designing an intuitive UI, and seamlessly integrating social media functionalities. Additionally, you'll gain valuable insights into player preferences and behavior using Unity's analytics tools. You'll also explore features of augmented reality in Unity 2022, enhancing your game's appeal.
By the end of this book, you'll be well-equipped to reap the power of Unity 2022 to build, optimize, and publish robust cross-platform mobile games with C#, as well as widening your skill set and enhancing your credentials as a game developer.

Doran Unity 2022 Mobile Game Development jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


Table of Contents - Building Your Game
- Project Setup for Android and iOS Development
- Mobile Input/Touch Controls
- Resolution-Independent UI

- Advanced Mobile UI
- Implementing In-App Purchases

- Advertising Using Unity Ads
- Integrating Social Media into Our Project
- Keeping Players Involved with Notifications
- Using Unity Analytics
- Remote Config
- Improving Game Feel
- Building a Release Copy of Our Game
- Submitting Games to App Stores
- Augmented Reality


1


Building Your Game


As we start on our journey of building mobile games using the Unity game engine, it’s important that you are familiar with the engine itself before we dive into the specifics of building things for mobile platforms. Although there is a chance that you’ve already built a game and want to transition it to mobile, there will also be those of you who haven’t touched Unity before or may not have used it in a long time. This chapter will act as an introduction to newcomers and a refresher for those coming back, and it will provide some best practices for those who are already familiar with Unity. While you may skip this chapter if you’re already familiar with Unity, I think it’s also a good idea to go through the project so that you know the thought processes behind why the project is made in the way that it is, so that you can keep it in mind for your own future titles.

In this chapter, we will build a 3D endless runner game in the same vein as series. In our case, we will have a player who will run continuously in a certain direction and dodge the obstacles that are in their way. We can also add additional features to the game easily, as the game will endlessly have new things added to it.

This chapter will be split into several topics. It will contain simple, step-by-step processes for you to follow. Here is an outline of our tasks:

  • Setting up the project
  • Creating the player
  • Moving the player through a C# script
  • Improving scripts using attributes and XML comments
  • Update function versus FixedUpdate function
  • Having the camera follow our player
  • Creating a basic tile
  • Making the game endless
  • Creating obstacles

Technical requirements


This book utilizes and , but the steps should work with minimal changes in future versions of the editor. If you would like to download the exact version used in this book, and there is a new version out, you can visit Unity’s download archive at https://unity3d.com/get-unity/download/archive.

You can also find the system requirements for Unity at https://docs.unity3d.com/2022.1/Documentation/Manual/system-requirements.html in the section.

You can find the code files for this chapter on GitHub at https://github.com/PacktPublishing/Unity-2022-Mobile-Game-Development-3rd-Edition/tree/main/Chapter01.

Setting up the project


Now that we have our goals in mind, let’s start building our project:

  1. To get started, open Unity Hub on your computer.
  2. From startup, we’ll opt to create a new project by clicking on the New button.
  3. Next, under Project Name, put in a name (I have chosen MobileDev), and under Templates, make sure that 3D is selected. Afterward, click on CREATE and wait for Unity to load up:

Figure 1.1 – Creating a 3D project

  1. After it’s finished, you’ll see the Unity Editor pop up for the first time:

Figure 1.2 – The Unity Editor

  1. If your layout doesn’t look the same as in the preceding screenshot, go to the top-right section of the toolbar and select the drop-down menu there that reads Layout. From there, select Default from the options presented:

Figure 1.3 – The Layout button

We now have opened Unity for the first time and have the default layout displayed!

Tip

If this is your first time working with Unity, then I highly recommend that you read the section of the , which you can access at https://docs.unity3d.com/Manual/UsingTheEditor.html.

Now that we have Unity open, we can actually start building our project.

Creating the player


To get started, we’ll build a player that will always move forward. Let’s start with that now:

  1. To get started, we will create some ground for our player to walk on. To do that, go to the top menu and select GameObject | 3D Object | Cube.
  2. From there, we’ll move over to the Inspector window and change the name of the object to Floor. Then, for the Transform component, set Position to (0, 0, 0). This can be done by either typing the values in or right-clicking on the Transform component and then selecting the Reset Position option.
  3. Then, we will set the Scale values of the object to (7, 0.1, 10):

Figure 1.4 – Creating the ground

In Unity, by default, 1 unit of space is representative of 1 meter in real life. So, our Scale values will make the floor longer than it is wide (X and Z), and we have some size on the ground (Y), so the player will collide and land on it because we have a Box Collider component attached to it by default.

Note

The Box Collider component is added automatically when creating a Cube object and is required to have objects collide with it. For more information on the Box Collider component, check out https://docs.unity3d.com/Manual/class-BoxCollider.html.

  1. Next, we will create our player, which will be a sphere. To do this, we will go to GameObject | 3D Object | Sphere.
  2. Rename the sphere to Player and set the Transform component’s Position values to (0, 1, -4):

Figure 1.5 – Positioning the player

This places the ball slightly above the ground and shifts it back to near the starting point. Note that the camera object (see the camera icon) is pointing toward the ball by default because it is positioned at (0, 1, -10).

  1. We want the ball to move, so we will need to tell the physics engine that we want to have this object react to forces, so we will need to add a Rigidbody component. To do so, with the Player object selected, go to the menu and select Component | Physics | Rigidbody. To see what happens now, let’s click on the Play button, which can be seen in the middle of the first toolbar:

Figure 1.6 – Current state of the game

As in the preceding screenshot, you should see the ball fall down onto the ground when we play the game.

Tip

You can disable/enable having the Game tab take up the entire screen when being played by clicking on the Maximize On Play button at the top, or by right-clicking on the Game tab and then selecting Maximize.

  1. Click on the Play button again to turn the game off and go back to the Scene tab, if it doesn’t happen automatically.

We now have the objects for both the floor and the player in the game and have told the player to react to physics! Next, we will add interactivity to the player through the use of code.

Moving the player through a C# script


We want the player to move, so in order to do that, we will create our own piece of functionality in a script, effectively creating our own custom component in the process:

  1. To create a script, we will go to the Project window and select the Create button in the top-left corner of the menu by clicking on the + icon, and then we will select...


Doran John P.:

John P. Doran is a passionate and seasoned Technical Game Designer, Software Engineer, and Author who is based in Incheon, South Korea. His passion for game development began at an early age. He later graduated from DigiPen Institute of Technology with a Bachelor of Science in Game Design. For over a decade, John has gained extensive hands-on expertise in game development working in various roles ranging from game designer to lead UI programmer working in teams consisting of just himself to over 70 people in student, mod, and professional game projects including working at LucasArts on Star Wars: 1313. Additionally, John has worked in game development education teaching in Singapore, South Korea, and the United States. To date, he has authored over 10 books pertaining to game development. John is currently a Technical Game Design Instructor at George Mason University Korea. Prior to his present ventures, he was an award-winning videographer.



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.