Book Image

Unity 2018 By Example - Second Edition

Book Image

Unity 2018 By Example - Second Edition

Overview of this book

Unity is the most exciting and popular engine used for developing games. With its 2018 release, Unity has become the primary source of both game development and virtual reality content. In Unity 2018 By Example, you’ll learn how to use Unity in order to make amazing games from popular genres - from action shooters to mind-bending puzzle games to adventure and Virtual Reality (VR) games. Even if you have no previous experience of using Unity, this book will help you understand the toolsets it provides in depth. In addition to this, you'll understand how to create time-critical collection games, twin-stick space shooters, platformers, and action-fest games with intelligent enemies. Finally, you'll get to grips with creating VR games with the new toolsets introduced by Unity to help you develop amazing VR experiences. To make things easier, you will be provided with step-by-step tutorials for making five great games in Unity 2018, along with a detailed explanation of all the fundamental concepts. By the end of this book, you’ll have established a strong foundation in making games with Unity 2018.
Table of Contents (16 chapters)
Unity 2018 By Example - Second Edition
Contributors
Preface
Other Books You May Enjoy
Index

Attack and Damage


Enemies should attack the player, and the player should attack the enemies. Both depend on the concept of attacking and taking damage. In this section, we'll use particle systems for inflicting damage, and we'll create script to take damage. First, let's create a player weapon by generating a new particle system. In VR, this object can be made a child of the hand controllers; each hand can have one weapon. In standard first-person mode, the particle system will be a single-fire weapon. To get started for the player attack, create a new particle system in the scene by choosing GameObject | Effects | Particle System. See Figure 10.12:

Figure 10.12: Creating a weapon particle system

Once added, we'll need to tweak a lot of settings to make it look like a plasma beam, or a laser cannon. Expand the Shape and Emission settings from the Object Inspector to reveal those particle system properties. See Figure 10.13:

Figure 10.13: Tweaking the Particle System for a plasma cannon

Change...