Adding the final details
Two things are missing here: the Enemy is not shooting any bullets and it doesn't have animations. Let's start by fixing the shooting issue:
- Add a
bulletPrefabfield of theGameObjecttype to ourEnemyFSMscript and a float field calledfireRate. - Create a function called
Shootand call it insideAttackBaseandAttackPlayer:Figure 19.68 – Shooting function calls
- In the
Shootfunction, place code that's similar to the code we used in thePlayerShootingscript to shoot bullets at a specific fire rate, as shown in the following screenshot. Remember to set the Enemy layer in your Enemy Prefab, in case you didn't previously, to prevent the bullet from damaging the Enemy itself. You may also want to raise the AI script a little bit to shoot bullets in another position or, better, add ashootPointtransform field and create an empty Object in the Enemy to use as the spawn position. If you do that, consider making the empty...