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

Cleaning up dead AI


Another thing that you will need to do when dealing with AIs is that if you're using Shooter AI, when they die, they don't disappear, at least by default. This adds realism to our world, but it's still very computationally expensive to have them around. Thankfully, we can add another component to make it quite easy for us to clean up enemies of our choice.

  1. From the Project tab, open the MyGame/Prefabs folder and select the UFPS_Enemy that we created earlier.

  2. From the Inspector tab, scroll all the way down and press the Add Component button. From here, navigate to Shooter AI | Clean Up After Death.

  3. By default, it has the Cleanup Time property set to 10, which means that after 10 seconds it will disappear. Since we want to see it quickly, change the value to 2.

  4. Save your project and start the game again.

After we kill our enemy, it will disappear! This will really help with things, such as performance and keep our game running smoothly!