top of page

Skillshot: Enemy Movement AI and Sound

It has been another lengthy gap since my last post due to working on some stuff I sadly cannot talk about currently, but I return with some pretty cool updates. As the title suggests, the enemies now move!

I started by adding a navMeshSurface component to the ground and a navAgent component to the baseEnemy prefab. This allows the enemies to map out routes through the level to get to a destination without walking into things. I also doubled the scale of the enemies and players to make everyone easier to hit and I tweaked the enemy navAgent variables to match the model and give an appropriate level of speed and responsiveness. Those variables are likely to change though.



















I then added code to the enemy script which saves the player's location while the enemy can see them. Once the player goes out of the enemy's view, the navAgent is then activated and the player's last known location is set as the enemy's destination, causing them to run to that location, effectively chasing after the player.


I then added code to the player's weapon script which causes it to alert all nearby enemies when fired, setting their destination to be the firing location, giving the illusion of enemies "hearing" the gunshot. Alongside this I added some placeholder firing sounds to the weapons.


To make the AI even smarter, and to stop enemies blocking each other's line of sight, I added similar code to the enemy script which causes them to alert other nearby enemies of the players location. Meaning if you are spotted by one enemy, he will quickly be calling in his buddies for backup.


In more minor news, as I was adding sound to the gun, I decided to add some to the UI to create a satisfying ping when you get a kill. This was nice but didn't have the immediate feedback of the classic Call of Duty hitmarker, and so I added that too. Now hitting an enemy causes a a set of diagonal lines to appear around your crosshair which play a subtle but informative noise to let you know you hit your target.



Comentarios


bottom of page