Menu

Tutorial #7: Grenade Attacks

Starting with Beta version 1.5, we have implemented grenade attacks.  A bot will use grenades, if he has any, during his ranged attack phase.

Our A.I. kit comes with a basic implementation of grenade attack decisions.  The grenade FSMs also have Area of Effect (AOE) damage built-in.

BASIC IMPLEMENTATION: We focused more on performance, so we reduced the number of Vector3 calculations per grenade phase.  So instead of having the bot calculate optimal grenade positioning, we have it simply toss the grenade at a force.  This means a lot of times the bot’s grenade will not land at the enemy’s feet.  The bot also determines randomly whether to toss a grenade or fire his gun.

ADVANCED IMPLEMENTATION: In the future, we will have an advanced add-on for purchase, where the bot will initiate a ton of Vector3 calculations to determine the optimal force/angle/height to throw the grenade.  This, however, will come at a performance cost.  Additionally, the bot will no longer use random grenade tosses, but only toss the grenade given a certain number of enemies in the area, to maximize area of effect.

 

STEP 1: In the Attack FSM: Enable grenade attacks on the bot. Simply set “charSTAT_GrenadeChance” to anything above 0.  Likewise, set it to 0 (zero) to turn off grenade attacks.  The following parameters pertain to the grenade attack for the bot.

1

 

 

STEP 2: Drag a grenade prefab into the bot’s slot. For this demo, just use the Grenade Template.

2

 

 

STEP 3: Edit grenade damage and explosion effect.  Grenade damage is set inside the Grenade prefab itself, not the bot.  So click the Grenade prefab and edit the FSM variables:

3

 

 

STEP 4 (optional): Create your own custom grenade or use a custom grenade model. It’s easy to make your own custom grenade or model.  Drag the GrenateTemplate into your scene. Open up the hierarchy and replace the child model with your own raw model.  Then drag the new grenade prefab into your Assets folder to create a usable prefab.

4