Melee Combat Behavior
This guide walks through configuring the melee attack combat behavior for an AI boss entity (Bull Boss New), including setting up pre-combat delays, distance range groups, weapon hitboxes, weapon trail effects, audio triggers, and animation events.
1. Overview & General Parameters
Before configuring specific attack abilities, set the overarching combat timings and distance rules for the boss.
Steps
- Select the Bull Boss New GameObject in the hierarchy.
- In the inspector, expand Pre-Combat Behaviors:
- Change Initial Pre-Combat Delay to
4. - Expand the Combat Attack System:
- Set Initial Attack Delay to
2seconds. - Set Combat Forget Distance to
100.
Note: If the target/player moves further than
100meters away, the boss will drop combat and enter the Non-Combat Behavior State.
2. Phase Layers & Distance Range Setup
Configure the health range and distance parameters under which the melee attack triggers.
Steps
- Click Add Phase Layer:
- Set Min Health to
0. - Set Max Health to
100. - Click Add Distance Range Subgroup:
- Set Min Distance to
0. - Set Max Distance to
20. - Ensure Play in Sequence and Do Not Repeat Last are unchecked.
- Set Min Attempt Delay to
3seconds. - Set Max Attempt Delay to
4seconds.
3. Configuring the Melee Ability Entry Group
Define the specific properties for the melee attack sequence.
Steps
- Click Add Ability Entry Group and name it
Melee Attack. - Set the Melee Attack Probability Slider to
100%(ensures this ability always plays during this combat phase). - Adjust the movement and engagement parameters:
| Parameter | Recommended Value | Description |
| :--- | :--- | :--- |
| Look Mode |
Target| Boss faces the target during the attack. | | Move Speed |2| Movement speed while engaging target. | | Move Animation |Walking| Animation state while moving toward player. | | Stopping Distance |2| Distance at which the boss stops moving toward the target. | | Re-Engage Distance |5| If target moves > 5m away, boss resumes chasing until 2m away. | | Attack Duration |10| Duration (in seconds) the boss continues attacking before re-evaluating state. | | Sequential | Checked | Plays animations in order (uncheck for random selection). | | Min/Max Attack Delay |1| Delay between consecutive attack animations (plays full animation clip first). |
4. Animation Setup
Add the required attack animations to the boss's animator component.
Steps
- Scroll down to the Animation Setup Tool and expand it.
- Under your project assets (
Animationsfolder), locateAttack 4andAttack 5. - Drag and drop
Attack 4andAttack 5into the tool: - Rename them to
Attack 2andAttack 3for clarity (assumingAttack 1is already present). - Click Add to Animator.
- Scroll back up to the Melee Attack Ability Entry Group, click the
+icon, and assign the attack animations: - Slot 1:
Attack 1 - Slot 2:
Attack 2 - Slot 3:
Attack 3 - Set Idle Delay to
0(or1) and selectIdleas the fallback animation state.
5. Hitbox Setup & Animation Events
Set up damage dealing by attaching a Hitbox component to the weapon and triggering it via Animation Events.
5.1 Setting up the Hitbox Component
- Select the weapon object (e.g.,
Spiky Weapon -> Damage Point). - Click Add Component and search for
Hit Box. - Configure the Hit Box settings:
- Damage:
5 - Owner: Drag and drop
Bull Boss New. - Compare Enemy: Checked (Drag
Bull Boss Newinto the Team Member script slot if prompted). - Activation Mode:
Manual - Deactivate Hitbox on Hit: Unchecked
- Deactivate Hitbox after Time: Unchecked
- Destroy Mode on Hit:
Do Not Destroy - Select
Bull Boss Newagain, expand the Hitbox Controller, click+, and assign theDamage Pointobject.
5.2 Binding Hitbox via Animation Events
- Open Window -> Animation -> Animation.
- Select the
Attack 1animation clip. - Scrub the timeline to where the strike begins:
- Click Add Event -> Choose
Hitbox Controller -> ActivateHitbox. - Scrub to where the strike ends:
- Click Add Event -> Choose
Hitbox Controller -> DeactivateHitbox. - Repeat these steps for
Attack 2andAttack 3.
6. Weapon Trail Effects (Slash Manager)
Create visual slash trails for weapon swings using the Trail Renderer and Slash Manager.
6.1 Trail Object Creation
- Right-click on the weapon object (
Spiky Weapon) -> Create Empty and name itTrail. - Add a Trail Renderer component:
- Width: Set curve ending at
0(Top value:1). - Time:
2 - Min Vertex Distance:
0.01 - Corner Vertices / End Cap Vertices:
16 - Material: Assign
/Material(located underMy Models -> Bull -> Materials). - Position: Adjust local transform (e.g.,
Y = 6) to align with the weapon edge.
6.2 Slash Manager Configuration
- Select
Bull Boss Newand expand the Slash Manager script. - Click Add New Configuration for each attack:
| ID And Animation String ID | Wind Up Delay | Swing Active Duration | Weapon Trail Object |
|---|---|---|---|
Attack 1 |
0.7 |
0.5 |
Trail |
Attack 2 |
Default | Default | Trail |
Attack 3 |
Default | Default | Trail |
- Open Window -> Animation -> Animation.
- On frame
0of each attack animation clip (Attack 1,Attack 2,Attack 3): - Add Event -> Select
SlashManager.ActivateSlashWithID. - Pass the string parameter matching the ID (
Attack 1,Attack 2, orAttack 3). - Disable/Deactivate the
TrailGameObject in the hierarchy by default.
7. Sound Effects Configuration
Add audio triggers using the Universal Sound Player.
Steps
- Select
Bull Boss Newand open the Animation window. - Select each attack clip (
Attack 1,Attack 2,Attack 3). - Position the playhead on the frame where the swing sound should play.
- Click Add Event:
- Function:
UniversalSoundPlayer -> PlayAudioAction. - String Parameter: Pass the corresponding audio action ID (e.g.,
Attack Sound 1,Attack Sound 2,Attack Sound 3).
8. Testing & Troubleshooting Checklist
Before entering Play Mode, verify the following setup steps:
- [ ] Trail Object: Disabled in the hierarchy.
- [ ] Game Audio: Unmuted in the Game Window.
- [ ] Idle Delay: Set to
0in the Enemy Ability System (for instant transitions back to idle after combat ends).