Book Image

Building an FPS Game with Unity

By : John P. Doran, jamal seaton
5 (1)
Book Image

Building an FPS Game with Unity

5 (1)
By: John P. Doran, jamal seaton

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

Adding trees


Hills typically aren't just grass. Vegetation can be used to block a player's visibility and give a better look to our environment. Perform the following steps to add tress:

  1. From the Project tab, go to the Assets/Terrain Assets/Trees Ambient-Occlusion folder and drag and drop a tree into the world (I'm using ScotsPineTree).

    By default, these trees do not contain collision information, so our player could just walk through it. This is actually great for the areas that the player will not reach, as we can add more trees without having to do meaningless calculations. But we need to stop the player from walking through them, so we're going to add a collider.

  2. To do so, select the tree, select Component | Physics | Capsule Collider, and then change the Radius value to 1.

    Note

    You have to use a Capsule Collider for collision to carry over to the Terrain.

  3. After this, move our newly created tree into the Assets\MyGame\Prefabs folder under the Project tab and change its name to CollidingTree...