Technical Blog : Week 2
- Ryan Vafiadis
- Jan 15, 2017
- 2 min read
Started research on good FPS AI for line of sight, peripheral, hearing, patrol, and changes in behavior based on difficulty.
Implemented a camera for line of sight by calculating the frustum planes and testing them against the player's bounds as an AABB. With this functionality I was able to calculate when the player was being seen by the enemy.
Next I used Quaternion rotations and LERP in order to have the AI face the player when they were in sight.
By using Raycasting I was able to compare colliders in front of the AI so that the AI could no longer see the player through obstacles.
After toying with the timers to transition between certain states, I decided to scrap that idea and try a rating system for the caution and alert states.
Rating system resulted in a much better design. There's now a smooth translation from patrol state to caution state to alert state back to caution state and finally back to patrol state based on the increase and decrease of points collected by the rating system when the player is in and out of the AI's sights.
Created a behavior for the AI to flee while attacking and will hide behind cover. Modified attack behavior so that the AI will not attack wile hiding in cover. Changed targeting behaviors to instead generate a list of potential enemies , then create a smaller list of the visible targets. Currently the selected target target will be random if the resulting list contains more than a single object, later a priority system can be implemented if desired.
Worked with Liston to create a new script than instantiates bullets when the attack state is active.
댓글