Pre Combat Behaviour
This guide covers the setup process for Pre-Combat Behaviours using the Boss AI Toolkit in Unity. This covers how to configure non-offensive tactical actions—such as target-relative strafing or environment destruction—while waiting for main combat cooldowns.
1. Global Pre-Combat Settings
Select your enemy GameObject (Bull Boss New) and locate the Pre-Combat Abilities section in the Inspector.
┌────────────────────────────────────────────────────────┐
│ PRE-COMBAT GLOBAL SETTINGS │
├──────────────────────────┬─────────────────────────────┤
│ Property │ Recommended Default Value │
├──────────────────────────┼─────────────────────────────┤
│ Initial Pre-Combat Delay │ 2.0 s │
│ Min Pre-Combat Wait │ 3.0 s (or 5.0 s for testing)│
│ Max Pre-Combat Wait │ 3.0 s (or 5.0 s for testing)│
│ Sequential │ Enabled (Checked) │
│ NavMesh Search Range │ 40.0 (Visualized by Gizmos) │
│ Stopping Distance │ 3.0 │
└──────────────────────────┴─────────────────────────────┘
Parameter Explanations
- Initial Pre-Combat Delay: The waiting duration (in seconds) after the game starts before the AI enters its pre-combat loop.
- Min / Max Pre-Combat Wait: The delay between consecutive pre-combat abilities. Setting this (e.g.,
3-3or5-5) ensures a fixed resting period before triggering the next action. - Sequential: When enabled (✓), abilities execute in order from top to bottom. If disabled, abilities are selected randomly.
- NavMesh Search Range: Defines the radius within which the AI looks for valid movement points or breakable objects. Can be visualized via Inspector Gizmos.
- Stopping Distance: Distance at which the AI completes its movement relative to the target point.
2. Setting Up the Strafing Ability
Strafing allows the AI to stay mobile while awaiting attack availability, switching movement direction based on target proximity.
Step 1: Configure Ability Properties
Click Add Pre-Combat Ability and set up the following parameters:
- Ability Type: Set to
Normal Ability. - Move to Point: Enable (✓).
- Max Move Time: Set to
6seconds (caps movement duration even if the target point is far away). - Movement Radius: Set to
20. - Allowed Directions: Select Left, Right, and Backward.
- Check Interval Seconds: Set to
2seconds (frequency at which the AI evaluates its movement direction relative to the target). - Configurations Count: Set to
3(matching the number of allowed directions).
Step 2: Download & Import Mixamo Animations
Download three strafing animations from Mixamo: * Right Strafe Walking * Left Strafe Walking * Unarmed Walk Back
Asset Import Settings
- Select all three imported animation clips in Unity.
- Rig Tab: Change Animation Type to
Humanoidand Click Apply. - Animation Tab:
- Enable Loop Time and Loop Pose (✓).
- Set Based Upon (Root Transform Rotation) to
Originaland Click Apply.
Step 3: Register Animations in Animator & Script
- Select
Bull Boss Newand expand Animation Setup Tool. - Assign the clips and parameters:
| Source Clip | Assigned Parameter Name |
|---|---|
| Left Strafe Walking | Left Strafe |
| Right Strafe Walking | Right Strafe |
| Unarmed Walk Back | Walk Back |
- Click Add to Animator and Optimize Animation Clips. (You can delete the imported raw
.fbxfiles after optimization). - Inside the Pre-Combat Ability inspector, map each direction:
| Direction Configuration | Matching Direction | Animation to Play | Move Speed |
|---|---|---|---|
| Option 1 | Backward | Walk Back |
2.0 |
| Option 2 | Right | Right Strafe |
2.0 |
| Option 3 | Left | Left Strafe |
2.0 |
- Set Fallback Move Animation to
Walking. - Set Idle Animation to
Idle.
Tip (Smooth Transitions): In the Animator Controller, select the transitions originating from
Any Stateto each strafe clip and increase Transition Duration from0.1to0.5for smoother animation blending.
3. Setting Up the Break Objects Ability
The Break Objects ability instructs the AI to locate and destroy destructible environmental props during pre-combat.
┌────────────────────────┐
│ AI Finds Breakable │
│ Object in Radius │
└───────────┬────────────┘
│
▼
┌────────────────────────┐
│ Navigates to Object │
│ (Walking Animation) │
└───────────┬────────────┘
│
▼
┌────────────────────────┐
│ Plays Attack/Punch Anim│
└───────────┬────────────┘
│
▼
┌────────────────────────┐
│ Weapon Collider Hits │
│ Object Trigger Box │
└───────────┬────────────┘
│
▼
┌────────────────────────┐
│ Static Mesh Hidden │
│ Fragments Activated │
└────────────────────────┘
Step 1: Add and Configure the Ability
- Click Add Pre-Combat Ability (
+). - Set Ability Type to
Break Objects. - Check Find Closest Object (✓).
- Set parameters:
- Move Speed:
2.0 - Stopping Distance:
3.0 - Final Animation Delay:
2.0 - Move Animation:
Walking - Punch Animation:
Attack 1(Assign your melee attack clip via the Animation Setup Tool).
Step 2: Environment Object Setup (Breakable Object)
For an object to be breakable by the AI, it must meet the following structural requirements:
- Tag: Set GameObject tag to
BreakableObject. - Trigger Collider: Add a
Box Colliderwith Is Trigger enabled (✓). - Script: Attach the
Breakable Objectscript. - Child Objects:
- Static Object: Active by default; contains the clean
Mesh Renderer. - Destructible Object: Inactive by default; contains individual fractured mesh pieces, each with a
RigidbodyandColliderattached. - Assign both references in the
Breakable Objectscript and set Break Delay to1.0second.
Warning (Weapon Collider Requirement): The enemy's weapon (or attacking body part) must have an active collider (e.g., a
Capsule Colliderattached to a childDamage Pointobject). If no collider triggers the object's hit area, the break action will fail to initiate.
Step 3: Mesh Fracturing Tool (Optional)
To create custom destructible models directly inside Unity:
- Open Tools < Boss AI Toolkit < Mesh Fracture.
- Drag and drop your static mesh (e.g.,
Stone Pillar) into the window. - Set Number of Pieces:
- Mobile Platforms: Recommended
8–10pieces max to maintain physics performance. - PC / Console: Higher piece counts allowed.
- Click Start Fracture Process.
- Click Save as Mesh and choose your target directory.
4. Execution Logic & Testing Workflow
Sequential Execution Flow
When multiple abilities are added with Sequential enabled:
┌────────────────────────────────────────────────────────────────────────┐
│ PRE-COMBAT RUNTIME FLOW │
├────────────────────────────────────────────────────────────────────────┤
│ 1. Game Start ──► Wait [Initial Pre-Combat Delay: 2s] │
│ 2. Execute Ability 1 (e.g., Break Object 1) │
│ 3. Wait [Pre-Combat Delay: 5s] │
│ 4. Execute Ability 2 (e.g., Strafing for Max 6s) │
│ 5. Wait [Pre-Combat Delay: 5s] │
│ 6. Execute Ability 1 (Target next closest Breakable Object, if any) │
│ 7. If no breakable objects remain ──► Fall back to Strafing │
└────────────────────────────────────────────────────────────────────────┘
Testing Checklist
- [x] Verify enemy switches from Left, Right, and Backward strafings dynamically as the player shifts positions around the enemy.
- [x] Ensure weapon
Capsule Colliderproperly contacts the object trigger zone. - [x] Adjust Break Delay value per object to sync the physical break effect precisely with the impact frame of the attack animation.