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 ...

Get Building an FPS Game with Unity now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.