Book Image

Building a Game with Unity and Blender

Book Image

Building a Game with Unity and Blender

Overview of this book

In the wake of the indie game development scene, game development tools are no longer luxury items costing up to millions of dollars but are now affordable by smaller teams or even individual developers. Among these cutting-edge applications, Blender and Unity stand out from the crowd as a powerful combination that allows small-to-no budget indie developers or hobbyists alike to develop games that they have always dreamt of creating. Starting from the beginning, this book will cover designing the game concept, constructing the gameplay, creating the characters and environment, implementing game logic and basic artificial intelligence, and finally deploying the game for others to play. By sequentially working through the steps in each chapter, you will quickly master the skills required to develop your dream game from scratch.
Table of Contents (16 chapters)
Building a Game with Unity and Blender
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding in-game items and power-ups


Next, you will learn how to alter the player's attributes by creating in-game items that can be picked up by the player. Let's create the prefab in the Unity Editor before proceeding to the script. I did a simple cross-shape prefab using boxes, removed the colliders from the boxes, and attached a sphere collider component to it, which are marked as a trigger. I also set its tag as Item so that we can use it later. The tag is a very useful functionality in Unity, which allows you to group game objects into the same category for your scripts to identify them during gameplay. For example, you might define Player and Enemy tags for player-controlled characters and non-player characters respectively.

Instead of creating an individual script for every item of different purpose, we can create one universal power-up script that alters different player attributes depending on how we set the variables.

Therefore, the first thing we need to add to the power-up script...