Game Development Reference
In-Depth Information
Note Be sure to configure the attack, patrol, and chase distances for the Enemy component in the Object
Inspector. For the Drone, I've used a Chase of 10, a Patrol of 30, and an Attack of 2. Also be sure to set the
Stopping Distance of the NavMeshAgent component to 1.5 or less, to stop the Enemy from walking through
the Player, but to allow enough “closeness” to make an attack possible.
Adding More Enemy Types
Implementation of the Drone enemy is now completed, which means we can “Prefab” him! That is,
we can now create a Prefab for this enemy, ready to duplicate and position him in the level wherever
we need additional Drone enemies. But, of course, CMOD will feature more than simply the Drone
enemies; there's the Tough Guy and Mr. Big Cheese, too. They are tougher and meaner Enemies.
However, their implementation requires only two additional classes, one for each Enemy type:
Enemy_ToughGuy and Enemy_Boss . Both of these classes will derive from the base Enemy class. This
means that all the core AI functionality and behavior inherited by the Drone will also be inherited by
the Tough Guy and Mr. Big Cheese.
In fact, the only critical ways in which the Tough Guy and Mr. Big Cheese differ from the Drone, and
from each other, is in terms of their damage strength , their health, and their attack range . In all other
respects, all of the Enemies are identical—even though they may seem very different to the gamer. This
is significant because it shows that, through class inheritance and by using varied assets, it's possible
to create the appearance of great variety and divergence atop a common and shared codebase.
Given the similarities between the Enemy types, the source code for the Tough Guy and Mr. Big
Cheese will not be listed here, although it can be found in the topic companion files for Chapter 7,
should you need further guidance on how to implement additional enemies. Take a look at Figure 7-19
for a level full of dangerous Enemies. Congratulations! You've now implemented another critical and
core mechanic into the FPS game CMOD.
Figure 7-19. CMOD, up and running with multiple Enemy types
 
Search WWH ::




Custom Search