Combat AI Code Example

Code Example: Combat AI

The purpose of this Combat AI demonstration is to showcase a fun and engaging branching combat AI and player combat system that was created in approximately 15 hours.

This demonstration focuses specifically on the Combat AI, with simple camera, animation, and character implementations in place to allow for the assessment of the combat AI. A debug widget is available to display the “brain” functions during gameplay.

It is important to note that this AI was created in 2018 and may not reflect my current skills or the most up-to-date techniques. This demonstration was intended to showcase my capabilities at the time it was created.


• Player can use input buffer for combos
• Some attacks (those at the end of combos) do not accept further input buffer
• Most attacks can be evade cancelled, except those at the end of combos
• Attacks at end of combos are indefensible
Player will orient itself towards the closest aggressive enemy, allowing for relative to player avatar input
Player can block or evade enemy attack
• A successful block will leave enemy on a staggered state and trigger bullet time for fun visuals and “feel”
•Player can evade backwards, laterally or forward when close to enemy to gain advantage. Lateral evasions from close up will rotate around the enemy to gain advantage towards its back
•Player can evade in any direction when not close to enemy, and it will stop upon proximity to a new close enemy
•Player can cancel an evade into some attacks during the last part of the evasion animation to allow for very fluid combo possibilities


• Enemies will attack player based on who is closer, with the other enemies leaving space for the fight, based on a circular EQS
• Enemies will try to get Player into a 3-hit combo, but will stop current combo if Player defends / evades and decide which next action to take
• Enemies will always end their completed combos with an indefensible attack which will stun player if hit, but which does not track player movement. Most attacks will track rotation so at to not make the enemies look “too dumb/easy”
 Can defend, based on how many times they’ve seen an attack / combo. Enemies remember which attacks they’ve seen lately, which sets a chance to defend. The more the player uses the same attacks, the higher chance of enemy defending.
• Enemies can block, evade, or both in succession. At the moment this choice is weight based, but it could easily be context based.
• A successful block will leave Player on a staggered state
• Enemies are not able to defend when hit form behind their backs
 Enemies will try to counter attack after a successful defense. The timing is left intentionally loose so players have 1 chance to evade quickly, or else be punished
• Enemies will taunt player if he is hit by and indefensible attack or counter attack
Enemy attack tells are created with time dilation, as I did not have animations with correct tells