Fire Crystal Ant - AI

Version 4.1 by Adam Janus on 2026/01/19 20:49

Fire Crystal Ant

1. Introduction

  1. A low-level, early-game hostile creature.
  2. Introduce directional combat and basic telegraphed enemy attacks.
  3. Drops basic loot.

1768844705045-424.png

2. Enemy Behaviours

1768845201254-673.png


 

2.1 Patrol

1768845249390-619.png

  • Triggered by: Not engaged in any other behaviour OR end of Disengage behaviour
  • Shown behaviour: Picks a location within its [Patrol Distance], rotates towards it and moves until it reaches it at [Patrol Speed].
    • This is handled by a Custom Task and the MoveTo task of UE’s Behaviour Trees
    • A new random location is picked after [NextPatrolWait] 
  • Transition rule: Senses the Player by sight, hearing, colision or damage.
    • Senses are handled by Unreal Engine’s AIPerception component
    • Attacking an unaware Enemy triggers this behaviour
  • Animation:
    • Normal ant-walking animation,
    • On reaching patrol destination,

2.2 Approach

1768844705049-610.png

  • Triggered by: end of Patrol Behaviour 
  • Shown behaviour: the Enemy rotates towards the Player and moves towards their direction at [Approach Speed].
    • This is handled by the MoveTo task
  • Transition rule:  the Enemy stops moving when they are closer than [Attack Distance] from the Player and they still have the Player in their Line of Sight 
    • [Attack Distance] overrides the [Acceptable Radius] value in the MoveTo Task and is edited on a per-enemy basis based on their Design
  • Animation:
    • Faster ant-walking animation

2.3 Enemy Attack

1768844705050-879.png

  • Triggered by: end of Approach Behaviour 
  • Shown behaviour: the Enemy triggers an Attack Animation Montage or Move Animation Montage
    • Pincer attack is preferred usually.
    • Charge attack is preferred when:

      • Player is is outside of [Attack Distance] for more then 4 second. 
    • Abdomen Attack is preferred when:
      • Player has reached the [Hit Streak Limit].
        • Lower preference than Stinger Attack.
  • Transition rule: the Enemy evaluates if the Player is still within [Attack Distance] and in its Line of Sight and either Attacks again or starts the Approach Behaviour again 
  • Animation:
    • Described in 3.2 Enemy Attack.

2.4 Enemy Staggered

  • Triggered by: [Stagger Damage] >= [Stagger Limit]
  • Shown behaviour: the Enemy aborts all other Behaviours and triggers a Stagger Animation Montage and can't enter any other state while staggered.
  • Transition rule: upon ending the Stagger Animation Montage and waiting [Stagger Time] the Enemy evaluates if the Player is still within [Attack Distance] and in its Line of Sight and either starts the Attacks Behaviour or the Approach Behaviour

2.5 Enemy Disengage

1768844705052-455.png

  • Triggered by: the Player gets further than the Enemy’s [AreaOfInterest]
  • Shown behaviour: the Enemy rotates towards its [SpawnLocation] and goes back there
    • This is handled by the MoveTo task
  • Transition rule: upon reaching the [SpawnLocation] and waiting [NextPatrolWait] the Enemy starts the Patrol Behaviour

3. Action and Reactions

3.1 Attacking the Enemy

Upon registering damage, the following happens:

  • Particles are spawned at the first point of impact
    • If the flesh is hit, slightly bright gold particles. 1 burst: Short-lived and sparse.
    • If the armour is hit, dull grey particles. Smaller particles. 1 burst: Short-lived and even sparser.
  • A 2D Sound Effect is spawned
    • If the flesh is hit, a satisfying crunch sound.
    • If the armour is hit, a dull clang sound.
  • Additionally, if flesh is hit, the crystals on the ant’s body glimmer in dull red (emissive).
  • The Enemy receives damage based on the calculations in the CombatSystem_Design Document.
  • The Enemy receives Stagger Damage.

3.2 Enemy Attack

3.2.1 Pincer attack

The ant uses the pincers on its face to “bite” the player.

3.2.1.1 Animation

Wind-up:

  1. Extend the pincers over 0.5 seconds.
    1. Also, tilt the head back by 15 degrees from normal position (or the closest that’s noticeable to the player))
  2. Hold for 0.5 seconds.

Swing:

  1. Snap shut over 0.2 seconds.
  2. Snap the head forward by 15 degrees from normal position.
    1. Slam sound
  3. [Notify] Apply slashing damage according to the number of pincer colliders that overlap the player.

Recovery:

  1. Pincers reach normal positions over 0.2 seconds.
  2. Cooldown for 2 seconds.

3.2.2 Charge attack

The ant leaps at player character and deals damage on land.

3.2.2.1 Animation

Wind-up:

  1. Rises the wings over 0.5 seconds.
    1.     Start flapping the wings.
  2. Leaps forward while flapping the leaps (becomes airborne)
    1.     Spreads limbs while airborne
    2.     Curls head close to torso 

Swing:

(ant is airborne always for 1.75 seconds) 

  1. Ant flies at direction of player for 1 second.
  2. After 1 second, ants locks is landing spot at current player position. 
    1. Brings it limbs close together
    2. rises its heads backward 
    3. [Notifes] sounds 
      1. Loud high pitch scream
  3. In 0.75 seconds, ants lands at previously locked landing spot, and deals damage with sphere collider. 

Recovery:

  1. Body uncurls completely and the ant lands back on the ground over 0.5 seconds.
    1. Also, wings retract completely.
  2. becomes idle for 1.2 seconds.

3.2.3 Abdomen Slam

The ant spins its boddy and slams player character with its abdomen.

3.2.3.1 Animation

Wind-up:

  1. Ant curls into a C-Shape seen form top-down perspective for 1 second.
  2. Ant shakes it abdomen for 0.45 second. 
    1. [Notify] rattle snake sound is played 
    2. Ant rotation becomes locked.

Swing:

  1. Ant jumps while curled starts to spin along Z axis for 360 degrees. 
    1. Collision becomes overlaid on ant's abdomen. 
  2. While jumping, ants gradually uncurls it body until its fully uncurled by full 360 degrees. 

Recovery:

  1. Ant land  with previously locked rotation with body lowered close to ground. 
  2. At slowly rises for 2 seconds.
    1. While rising ants cant perform any other action

3.2 Enemy Stagger

  • When the received [Stagger Damage] >= [Stagger Limit] the Enemy starts the Stagger Behaviour
  • After completing the Staggered Behaviour the [Stagger Damage] gets reset to 0
  • The received [Stagger Damage] goes down over time if new [Stagger Damage] is dealt every [Stagger Recovery Time]

3.4  Defeating the Enemy 

  • Upon reaching 0 HP the Enemy becomes ragdoll and stops using its Behaviour Tree.
  • Looting is enabled

4. Instance Editables

Variable

Type

Description 

Health Points

Float

The Enemy’s health

Attack Distance

Float

How far from the Player the Enemy starts to attack

Stagger Taken

Float

The amount of received Stagger value

Stagger Limit

Float

The amount of Stagger Damage to initiate the Stagger Behaviour

Stagger Time 

Float

The duration of the Stagger Behaviour

Stagger Recovery time 

Float

How long it takes for the Stagger Damage to reduce while not taking damage 

Patrol Speed 

Float

The Speed of Movement in the Patrol Behaviour 

Approach Speed

Float

The Speed of Movement in the Approach Behaviour 

Next Patrol Wait 

Float

How long to wait before going to the next Patrol Point 

Patrol Distance

Float

How far from Spawn can the Enemy pick a Patrol Point

Pincer attack Damage

 

Float

How much Damage the Enemy deals by Pincer attack

abdomen Attack Damage

Float

How much Damage the Enemy deals by abdomen attack

Charge attack Damage  

Hit Streak

Integer

Number of hits player has made without taking damage

Hit Streak Limit

Integer

The amount of hit streak before preferring Stinger Attack

Dropped Loot

Array of item structs

  • Item
  • Fixed quantity or range?
  • Amount

The items to drop when the Enemy dies.