Friday, 30 January 2015

Stun Attack

After getting a melee attack in, the next attack added was a stun attack. This attack stuns an enemy fot a set amount of time, allowing the player to either attack the enemy easier, or run away in order to regain some health.

The stun attack works similar to the melee in that it checks a trigger collider in order to determine whether or not the enemy can be attacked.  For this attack to work I added a new bool variable to the AI Attributes to check whether or not the enemy was stunned. This was used by the attack, by checking if the user had pressed the 'KeyPad 1' button, and canAttack was true. If both of these were true then the isStunned bool in the ai attributes was turned to be true.

The timer was set in the AI Attributes script too. In the update loop, there is a check to see if the enemy is stunned, if so then the movement was disabled and the timer would start counting down. when the timer was at zero the the enemy was un-stunned.