Enabling melee attacks are very simple. This section describes the Melee system and how to tweak the settings.
Every bot comes with melee capability. The action process flow works something like this:
[Bot detects enemy in melee range] -> [Bot initiates melee animation] -> [Bot sends melee damage] -> [Bot waits for next melee attack]
STEP 1: In Attack FSM, Enable Melee attacks on the bot
STEP 2: Setup melee on-hit effects. Drag any particle or explosion effect into this slot. If you noticed, this can also be changed at run time. There are no special scripts or FSMs on the particle effect prefab…any particle or explosion effect will work.
STEP 3: Tweak the melee parameters in the Attack FSM. The Melee Range is max distance the bot will start executing melee attacks. So if the bot has been shooting a gun, as soon as the enemy is within melee distance, the bot will switch to melee attacks and stop shooting. Melee Wait Sec denotes the number of seconds to wait before initiating another melee attack. Do not set this to ZERO or you could have problems!
STEP 4: Change the animation. The bots come with a default melee animation, which really isn’t a melee animation at all. It’s for prototyping only. We substituted the melee with the Unity free “StandingFireRPG” animation. This will make your bots look weird during melee fights. We suggest you change this animation to an actual melee animation (there are lots on the unity store). Simply go into the default animation controller, find the Melee layer, and switch out this animation.
STEP 5: (optional) If you want to change the animation name, you can do it here. Find the Attack FSM graph and, towards the bottom, find this section of 4 states. You can edit animation names here. Note: We have already done this for you with our pre-configured animation controller so most of the time you don’t need to change this, unless you’re not using a humanoid model.