Book Image

Building an FPS Game with Unity

5 (1)
Book Image

Building an FPS Game with Unity

5 (1)

Overview of this book

Table of Contents (18 chapters)
Building an FPS Game with Unity
Credits
Foreword
About the Author
Acknowledgment
About the Reviewers
www.PacktPub.com
Preface
Index

Building an explosive barrel


One of the first things we are going to look at is the common FPS staple: explosive barrels. These will allow the player to get a "leg up" on their enemies by causing explosions when damaged enough. They're also fairly simple to create.

  1. To start off, let's open up the level we created in the Chapter 5, Building Encounters (Chapter 5_5_ HealthPacksPickups.unity in the example files you can get from the Packt Publishing website).

    Let's get the implementation of the functionality to work correctly, then we can make it look nice.

  2. Create an object to represent our barrel. To do this, go to GameObject | 3D Object | Cylinder.

    This will create a 3D object that will look like a cylinder and give it a collider so that it blocks our player if he/she walks into it. It can also be hit by bullets.

  3. Change the object's name to Barrel. The default cylinder is a bit too large to be a barrel, so we will change the Y value of the Scale property to .75. Then, we will position it so that...