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.
From the Project tab, open the
MyGame/Prefabs
folder and select theUFPS_Enemy
that we created earlier.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.
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 to2
.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!