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

Preventing falls - collision


We don't want to have players always be stuck in walls, but we also want to make sure they don't fall down into the void. We can fix this problem with the addition of colliders:

  1. Select our "bridge" between the two areas and duplicate the object by hitting Ctrl + D. Reduce the newly created object's width to 1 unit and have it go up to be 3 units tall.

  2. Switch back to the Object mode, duplicate the object, and then move it to the other side.

  3. Select both the objects and, in the Prototype panel, click on the Set Collider button.

    You'll notice that there is now some nice semitransparent boxes in the areas where our full boxes were. These are colliders or rather volumes that will block the player upon colliding.

  4. Save the level and play the game.

You'll notice that the colliders aren't visible. They, in fact, block us from going out of the level. Perfect!