Chapter 8. Attacking

Fighting is an important part of a game's AI. For many games, fighting with the player is the main game mechanic and the most noticeable AI in the game. We will discuss the common methods for attack AI, how to make an enemy character chase and attack the player, and then have the enemy character take cover and hide from the player.

In this chapter, you will learn about:

  • Designing attack AI in RAIN 2.1.4
  • Creating basic chase attack AI
  • Creating and covering attack AI
  • Having AI attack in groups

An overview of attack AI

Attack AI is a large and much studied subject. When you start dealing with things such as different attack moves based on different player actions or having enemies coordinate attacks, the AI can become quite complex. However, designing good AI that attacks is the same as designing for other AI scenarios we have looked at so far in this book. First, we need sensors for our AI characters to perceive game events and to create aspects in the game world, tagging what they can sense. Then, we define behavior trees for the characters, directing them to change actions based on sensor response or other game states, such as running out of ammo. Defining different behaviors is the main part of setting up attack AI.

We'll look at two foundational AI attack behaviors in our demos in this chapter. The first will use multiple sensors on the AI to determine when to chase and when to stop and attack. The second behavior we will look at is the duck and cover type, where the enemy attacker will retreat to a safe position after attacking, and this is based on set navigation points. These are both best illustrated through demos, so let's start one now.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.253.239