Explore 1.5M+ audiobooks & ebooks free for days

Only $12.99 CAD/month after trial. Cancel anytime.

Unity from Zero to Proficiency (Advanced): Unity from Zero to Proficiency, #4
Unity from Zero to Proficiency (Advanced): Unity from Zero to Proficiency, #4
Unity from Zero to Proficiency (Advanced): Unity from Zero to Proficiency, #4
Ebook408 pages6 hoursUnity from Zero to Proficiency

Unity from Zero to Proficiency (Advanced): Unity from Zero to Proficiency, #4

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Newly Edited and Updated Version (Third Edition) for Unity 2019

Create multiplayer games and procedural levels and boost game performances without the headaches
Without this book, most people spend too long trying to develop and optimize their game the hard way. This book is the only one that will get you to create entertaining games and optimize your code without wasting so much time. It includes six chapters that painlessly teach you the necessary skills to automatise the creation of multiple game levels using only a few lines of code; you will create multiplayer games, and also make it possible for players to save their score (and other features) between games, even if they play on different devices; finally, you will learn to create fast and responsive games by optimizing your code.


What you will learn

  • After completing this book, you will be able to:
  • Create levels procedurally with C#, save yourself time, and speed-up the level design process.

  • Create levels randomly so that they are different every time the scene is loaded and add re-playability to your game.

  • Read XML files using C# and use the data within to create levels.

  • Create a space simulation using XML and C# and make your scene customizable.

  • Connect to a database from Unity to save and retrieve the player's score.

  • Create a simple network tank game with projectiles and explosions.

  • Create a Simon game.

  • Optimize your code and your project's structure


Content and structure of this book
The content of the books is as follows:

  • In Chapter 1, you will learn to create multiple scenes using a few lines of codes and see how it can save you a lot of time and also provide new and fresh levels to the player every time they play your game; along the way you will also create automatic 3D indoor and outdoor environments, a complete solar system simulation, and a randomly generated maze that you can use for your RPGs.
  • In Chapter 2, you will learn how to save data from your game to a database so that players' score can be saved between games, even if they play on different devices; along the way you will also learn to set-up your own database and combine C#, PHP, and MySQL (even if you have never used these before) to transfer data between Unity and your online database.
  • In Chapter 3, you will create a simple (but fun) network tank game and gain skills that will make it possible to create and deploy your own networked multi-player game.
  • In Chapter 4, you will design and implement your version of the Simon game, a very popular memory game in 1970s whereby the player has to memorize an increasing sequence of colors and sounds; along the way, you will learn how to create and use a finite state machine, a very important concept in computer science, to manage your game and the player's entries.
  • In Chapter 5, you will learn how to optimize your code so that your game is always fast and responsive and so that players enjoy their experience and want to play it again; along the way, you will also learn how to organize your project and use the best approach to develop your game.
  • Chapter 6 provides answers to frequently asked questions.

If you want to start creating multi-player games and procedural levels using a tried-and-tested method: download this book now!

LanguageEnglish
PublisherPatrick Felicia
Release dateFeb 14, 2018
ISBN9781980417880
Unity from Zero to Proficiency (Advanced): Unity from Zero to Proficiency, #4
Author

Patrick Felicia

Patrick Felicia is a lecturer and researcher at Waterford Institute of Technology, where he teaches and supervises undergraduate and postgraduate students. He obtained his MSc in Multimedia Technology in 2003 and PhD in Computer Science in 2009 from University College Cork, Ireland. He has published several books and articles on the use of video games for educational purposes, including the Handbook of Research on Improving Learning and Motivation through Educational Games: Multidisciplinary Approaches (published by IGI), and Digital Games in Schools: a Handbook for Teachers, published by European Schoolnet. Patrick is also the Editor-in-chief of the International Journal of Game-Based Learning (IJGBL), and the Conference Director of the Irish Symposium on Game-Based Learning, a popular conference on games and learning organized throughout Ireland.

Other titles in Unity from Zero to Proficiency (Advanced) Series (5)

View More

Read more from Patrick Felicia

Related to Unity from Zero to Proficiency (Advanced)

Titles in the series (5)

View More

Related ebooks

Programming For You

View More

Reviews for Unity from Zero to Proficiency (Advanced)

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Unity from Zero to Proficiency (Advanced) - Patrick Felicia

    Patrick Felicia

    ​Unity From Zero to Proficiency

    (Advanced)

    Copyright © 2019 Patrick Felicia

    All rights reserved. No part of this book may be reproduced, stored in retrieval systems, or transmitted in any form or by any means, without the prior written permission of the publisher (Patrick Felicia), except in the case of brief quotations embedded in critical articles or reviews.

    Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either expressed or implied. Neither the author and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

    First published: July 2016

    Second Edition published: February 2018

    Third Edition published: October 2019

    Published by Patrick Felicia

    ​Credits

    Author: Patrick Felicia

    ​About the Author

    Patrick Felicia is a lecturer and researcher at Waterford Institute of Technology, where he teaches and supervises undergraduate and postgraduate students. He obtained his MSc in Multimedia Technology in 2003 and PhD in Computer Science in 2009 from University College Cork, Ireland. He has published several books and articles on the use of video games for educational purposes, including the Handbook of Research on Improving Learning and Motivation through Educational Games: Multidisciplinary Approaches (published by IGI), and Digital Games in Schools: a Handbook for Teachers, published by European Schoolnet. Patrick is also the Editor-in-chief of the International Journal of Game-Based Learning (IJGBL), and the Conference Director of the Irish Conference on Game-Based Learning, a popular conference on games and learning organized throughout Ireland.

    ​Support and Resources for this Book + FREE BOOK

    As a new reader of my book series, and to thank you for choosing this book, I would like to offer you a free book. So, to receive your book, just email me at [email protected] with a screenshot of your receipt and I will send you a FREE copy of the book A Quick Guide to Artificial Intelligence (worth $3), a book that will extend the content provided in this book and help you to create levels faster for your games. After receiving your free book, you will also receive weekly updates and FREE tutorials on Unity 2017.

    >> CLAIM YOUR FREE BOOK <<

    To complete the activities presented in this book you need to download the startup pack on the companion website; it consists of free resources that you will need to complete your projects, including bonus material that will help you along the way (e.g., cheat sheets, introductory videos, code samples, and much more).

    These resources also include the final completed project so that you can see how your project should look like in the end.

    Amongst other things, the resources for this book include:

    All the C# scripts used in this book.

    Cheat sheets with tips on how to use Unity.

    3D characters and animation that you can use in Unity.

    A library of over 40 tutorials (video or text).

    To download these resources, please do the following:

    Open the following link: http://learntocreategames.com/books/

    Select this book ("Unity from Zero to Proficiency - Advanced").

    On the new page, click on the link labelled "Book Files", or scroll down to the bottom of the page.

    In the section called "Download your Free Resource Pack, enter your email address and your first name, and click on the button labeled Yes, I want to receive my bonus pack".

    After a few seconds, you should receive a link to your free start-up pack.

    When you receive the link, you can download all the resources to your computer.

    This book is dedicated to Mathis & Helena

    ––––––––

    [  ]

    Table of Contents

    1 Reading Files and Creating Scenes Procedurally

    Building your environment from an array

    Creating an environment from a text file

    Using XML files for content creation

    Creating a Maze Procedurally

    Creating an environment like Minecraft procedurally

    Creating a virtual solar system based on an XML file

    Level Roundup

    2 Accessing and Updating a Database

    Introduction to Online Databases

    Accessing a database through PHP

    Passing data to a PHP script

    Accessing PHP from Unity

    Setting up your server

    Creating new tables

    Gathering data from Unity

    Level Roundup

    3 Creating a Networked Multi-Player Game

    Introduction

    Creating a networked scene

    Getting the tanks to fire missiles

    Inflicting damage to the opponent

    Fun add-ons

    Level Roundup

    4 Creating a Memory Game

    Introduction

    Creating the interface and the core of the game

    Detecting when buttons have been pressed

    Managing the game

    Handling clicks

    Creating different states for our game

    Playing a sequence of colors

    Creating a new sequence of colors

    Waiting for the user’s input

    Processing the user’s input

    Generating sound effects

    Level Roundup

    5 Optimizing your project, code and game performances

    Introduction

    Organize assets and objects (project structure)

    Coding Tips to program defensively

    Monitoring and improving performances (profiling)

    Advanced techniques

    Level Roundup

    6 Frequently Asked Questions

    Networking

    Accessing databases

    Reading Files

    Optimization

    7 Thank you

    ​Preface

    After teaching Unity for over 5 years, I always thought it could be great to find a book that could get my students started with Unity in a few hours and that showed them how to master the core functionalities offered by this fantastic software.

    Many of the books that I found were too short and did not provide enough details on the why behind the actions recommended and taken; other books were highly theoretical, and I found that they lacked practicality and that they would not get my students’ full attention. In addition, I often found that game development may be preferred by those with a programming background but that those with an Arts background, even if they wanted to get to know how to create games, often had to face the issue of learning to code for the first time.

    As a result, I started to consider a format that would cover both: be approachable (even to the students with no programming background), keep students highly motivated and involved using an interesting project, cover the core functionalities available in Unity to get started with game programming, provide answers to common questions, and also provide, if need be, a considerable amount of details for some topics.

    This book series entitled Unity From Zero to Proficiency does just this. In this book series, you have the opportunity to play around with Unity’s core features, and essentially those that will make it possible to create an interesting 3D game rapidly. After reading this book series, you should find it easier to use Unity and its core functionalities.

    This book series assumes no prior knowledge on the part of the reader, and it will get you started on Unity so that you quickly master all the wonderful features that this software provides by going through an easy learning curve. By completing each chapter, and by following step-by-step instructions, you will progressively improve your skills, become more proficient in Unity, and create a survival game using Unity’s core features in terms of programming (C# and JavaScript), game design, and drag and drop features.

    In addition to understanding and being able to master Unity’s core features, you will also create a game that includes many of the common techniques found in video games, including: level design, object creation, textures, collision detection, lights, weapon creation, character animations, particles, artificial intelligence, and a user interface.

    Throughout this book series, you will create a game that includes both indoor and outdoor environments, where the player needs to finds its way out of the former through tunnels, escalators, traps, and other challenges, avoid or eliminate enemies using weapons (i.e., gun or grenades), drive a car or pilot an aircraft.

    You will learn how to create customized menus and simple user interfaces using Unity’s UI system, and animate and give (artificial) intelligence to Non-Player Characters (NPCs) who will be able to follow your character using Mecanim and Navmesh navigation.

    [  ]

    ​Content Covered by this Book

    Chapter 1, Reading Files and Creating Scenes Procedurally, gets you to create your scenes fast using a wide range of advanced techniques so that you can create your scene using text or image files and read them at run time without the need to add objects manually to your scene. It is also illustrated how these techniques can be used for data visualization by combining advanced C# coding and XML files.

    Chapter 2, Accessing and Updating a Database, helps you to understand how to transfer data between Unity and a database. It explains how to create your database, and how to access it through the use of a combination of C#, PHP and MySQL.

    Chapter 3, Creating a Networked multi-player game, explains and illustrates how you can create a simple network game. You will use UNET, Unity’s built-in networking features and create a simple tank game where two remote users can challenge each other in the same game.

    Chapter 4, Creating a Memory Game, shows you how to create a game where the player has to memorize and to play an increasing sequence of colors and sounds, in a similar way as the Simon game that was popular in the 80s. You will learn how to create and generate audio within Unity and change the sounds’ frequency, to detect when a player has pressed a button, to generate colors at random, and also to record the sequence entered by the player and then compare it to the correct sequence

    Chapter 5, Optimizing your Project, your Code and your Game Performances, explains how you can optimize your time and your game, using simple, yet efficient, steps. In this chapter you will learn how to avoid common issues that could slow down your game; you will learn how to identify and choose best coding practices to make your code more efficient, along with some tricks that you can use in Unity to boost the performances of your game.

    Chapter 6 provides answers to Frequently Asked Questions (FAQs) related to the topics covered in this book (e.g., networking, databases, procedural content generation or optimization).

    Chapter 7 summarizes the topics covered in the book and provides you with more information on the next steps.

    What you Need to Use this Book

    To complete the project presented in this book, you only need Unity 2019, or a more recent version, and to also ensure that your computer and its operating system comply with Unity’s requirements. Unity can be downloaded from the official website (http://www.unity3d.com/download), and before downloading, you can check that your computer is up to scratch on the following page: http://www.unity3d.com/unity/system-requirements. At the time of writing this book, the following operating systems are supported by Unity for development: Windows XP (i.e., SP2+, 7 SP1+), Windows 8, and Mac OS X 10.6+. In terms of graphics card, most cards produced after 2004 should be suitable.

    In terms of computer skills, all knowledge introduced in this book will assume no prior programming experience from the reader. So for now, you only need to be able to perform common computer tasks, such as downloading items, opening and saving files, be comfortable with dragging and dropping items and typing, and relatively comfortable with Unity’s interface. This being said, because the focus of this book is on programming with C# and optimizing your games, and while all steps are explained step-by-step, you may need to be relatively comfortable with Unity’s interface, coding in C#, as well as creating and transforming objects.

    So, if you would prefer to become more comfortable with Unity and C# programming prior to starting this book, you can download the first book in the series called Unity From Zero to Proficiency (Foundations), the second book in the series called Unity from Zero to Proficiency (Beginner), or the third book in the series called Unity from Zero to Proficiency (Intermediate). These books cover most of the shortcuts and views available in Unity, as well as how to perform common tasks in Unity, such as creating objects, transforming objects, importing assets, using navigation controllers, creating scripts or exporting the game to the web. They also explain how to code using C# along with good coding practices.

    Who this Book is for

    If you can answer yes to all these questions, then this book is for you:

    Would you like to learn how to optimize your code?

    Would you like to know how to structure your code neatly?

    Can you already code in C#?

    Would you like to discover how to create a multi-player game?

    Although you may have had some prior exposure to Unity and coding, would you like to delve more into Unity and understand its advanced functionalities in more detail?

    Who this Book is not for

    If you can answer yes to all these questions, then this book is not for you:

    Can you already create a multi-player game?

    Can you understand and apply common design patterns to your code?

    Are you looking for a reference book on Unity programming?

    Are you an experienced (or at least advanced) Unity user?

    If you can answer yes to all four questions, you may instead look for the next book series on the official website.

    How you will Learn from this Book

    Because all students learn differently and have different expectations of a course, this book is designed to ensure that all readers find a learning mode that suits them. Therefore, it includes the following:

    A list of the learning objectives at the start of each chapter so that readers have a snapshot of the skills that will be covered.

    Each section includes an overview of the activities covered.

    Many of the activities are step-by-step, and learners are also given the opportunity to engage in deeper learning and problem-solving skills through the challenges offered at the end of each chapter.

    Each chapter ends-up with a quiz and challenges through which you can put your skills (and knowledge acquired) into practice, and see how much you know. Challenges consist in coding, debugging, or creating new features based on the knowledge that you have acquired in the chapter.

    The book focuses on the core skills that you need; some sections also go into more detail; however, once concepts have been explained, links are provided to additional resources, where necessary.

    The code is introduced progressively and is explained in detail.

    You also gain access to several videos that help you along the way, especially for the most challenging topics.

    Format of each Chapter and Writing Conventions

    Throughout this book, and to make reading and learning easier, text formatting and icons will be used to highlight parts of the information provided and to make it more readable.

    Special Notes

    Each chapter includes resource sections, so that you can further your understanding and mastery of Unity; these include:

    A quiz for each chapter: these quizzes usually include 10 questions that test your knowledge of the topics covered throughout the chapter. The solutions are provided on the companion website.

    A checklist: it consists of between 5 and 10 key concepts and skills that you need to be comfortable with before progressing to the next chapter.

    Challenges: each chapter includes a challenge section where you are asked to combine your skills to solve a particular problem.

    Author’s notes appear as described below:

    Author’s suggestions appear in this box.

    Code appears as described below:

    public int score;

    public string playersName = Sam;

    Checklists that include the important points covered in the chapter appear as described below:

    ​How Can You Learn Best from this Book

    Talk to your friends about what you are doing.

    We often think that we understand a topic until we have to explain it to friends and answer their questions. By explaining your different projects, what you just learned will become clearer to you.

    Do the exercises.

    All chapters include exercises that will help you to learn by doing. In other words, by completing these exercises, you will be able to better understand the topic and gain practical skills (i.e., rather than just reading).

    Don’t be afraid of making mistakes.

    I usually tell my students that making mistakes is part of the learning process; the more mistakes you make and the more opportunities you have for learning. At the start, you may find the errors disconcerting, or that the engine does not work as expected until you understand what went wrong.

    Export your games early.

    It is always great to build and export your first game. Even if it is rather simple, it is always good to see it in a browser and to be able to share it with you friends.

    Learn in chunks.

    It may be disconcerting to go through five or six chapters straight, as it may lower your motivation. Instead, give yourself enough time to learn, go at your own pace, and learn in small units (e.g., between 15 and 20 minutes per day). This will do at least two things for

    Enjoying the preview?
    Page 1 of 1