In this tutorial we’ll set up damage detection, update start/end animations of actions and add a new player HUD.
This tutorial is part 4 of a mini-series covering real time battles with tab targeting. You can find the start of this series here.
We’ll update the enemy move AI to react to damage, change the start and end animations of abilities and items and set up a new player HUD.
This tutorial is based on the ORK 4 Unity Quickstart 3D tutorials using gamepad controls (with combined inputs), cast times and spawning enemies, but can be used in any project.
Update Move AI Detection #
We need to update the enemy’s move AI to detect combatants that damage them.
Open the ORK editor, navigate to Combatants > Move AIs and select the Hunt move AI.
Enemy Detection #
- Detect On Damage
Enable
Updating Action Start/End Animations #
If you’ve noticed during battle, using abilities or items will have the user first take a step forward before the action, and try to move back after the action.
This was set up in the quickstart 3D tutorials using the start and end animations for abilities and items. While this works great for the regular arena-style battles, it doesn’t work in real time battle areas.
So, let’s change this and only use them outside of real time battles.
New Start Animation Schematic #
Additionally, we’ll set up a new schematic that’ll rotate toward the target instead.
Open the schematic editor.
Rotate To #
Add Node > Movement > Rotation > Rotate To
This node is used to rotate an object toward another object.
- Object (Rotating Object)
Select: Machine Object - Rotate Component
Select: Transform - Lock Rotation
Enable X and Z, disable Y - Rotation Target
Select: Object - Object (Rotation Target)
Select: Starting Object
And that’s it for the schematic – click on Save Schematic and save it as RotateToTarget.
Updating the Settings #
Open the ORK editor and navigate to Battles > Battle Actions.
In case you’ve set up grid battles, you’ll already have multiple start animations set up. We need to change the MoveForward animation to not be used in real time battles and add a new start animation.
Ability Settings > Ability Start Animation (MoveForward) #
- All Battle Systems
Disable
Click on Add Battle System.
- Battle System
Select: Turn Based
Click on Add Battle System again.
- Battle System
Select: Active Time
Now we add a new battle animation.
Click on Add Battle Animation.
- Schematic Asset
Select: RotateToTarget
We need to limit it’s use to real time battles.
- All Battle Systems
Disable
Click on Add Battle System.
- Battle System
Select: Real Time
Ability Settings > Ability End Animation #
- All Battle Systems
Disable
Click on Add Battle System.
- Battle System
Select: Turn Based
Click on Add Battle System again.
- Battle System
Select: Active Time
Item Settings > Item Start Animation #
- All Battle Systems
Disable
Click on Add Battle System.
- Battle System
Select: Turn Based
Click on Add Battle System again.
- Battle System
Select: Active Time
Now we add a new battle animation.
Click on Add Battle Animation.
- Schematic Asset
Select: RotateToTarget
We need to limit it’s use to real time battles.
- All Battle Systems
Disable
Click on Add Battle System.
- Battle System
Select: Real Time
Item Settings > Item End Animation #
- All Battle Systems
Disable
Click on Add Battle System.
- Battle System
Select: Turn Based
Click on Add Battle System again.
- Battle System
Select: Active Time
New Player HUD Prefab #
Instead of using the Player Battle HUD that we set up in the quickstart 3D tutorials, we’ll create a new HUD based on it. We’ll add shortcut slots (to show the reuse times of the abilities) and only display the HUD for the player (i.e. the combatant controlled by the player). Most of the hard work has already been done in the quickstart 3D and shortcut HUD tutorials, we only need to make a few adjustments.
Locate your Player Battle HUD prefab (I’ve saved mine in Assets/UI/HUDs/) and duplicate it – rename the new copy to: Player RT Battle HUD
Open the new prefab for editing. It’ll currently look something like this (depending on which other tutorials you’ve followed with some more text and value bars):
We’ll adjust the position and size, change the background image, add shortcut slots at the bottom and make some layout adjustments.
Rect Transform #
With the root of the HUD selected, we’ll adjust the height and change the placement of the HUD to the bottom center of the screen.
Select the bottom center anchor preset.
Change the settings in this order:
- Height
Set to: 170 - Pivot
Set to: X=0.5, Y=0 - Pos Y
Set to: 0
Horizontal Layout Group #
You’ll notice the text now being in the center of the HUD. We’ll change the layout to align it to the upper left.
- Child Alignment
Select: Upper Left
Image #
Change the background image to BeigeBox instead of the current blue one.
- Image Source
Select: BoxBeige
Shortcut Slot List #
We’ll add a shortcut slot list setup using either the scene hierarchy’s context menu (ORK Framework > HUD > Shortcut > Shortcut Slot List (Horizontal Layout)) or the ORK toolbar (search for: Shortcut Slot List Horizontal).
The list is added as a child object and the HUD’s layout will try to place it – we don’t want this.
Layout Element #
Add a Layout Element component to the Shortcut Slot List child object of the HUD.
- Ignore Layout
Enable
Now, we’re free to place the shortcut slot list how we want.
Rect Transform #
Adjust the position and size, showing the slots at the bottom of the HUD.
Select the bottom stretch anchor preset.
- Pivot
Set to: X=0.5, Y=0 - Left
Set to: 200 - Right
Set to: 10 - Pos Y
Set to: 10 - Height
Set to: 100
HUD List Content #
The HUD List Content component is responsible for adding the shortcut slots (using prefabs).
- Prefab
Select: Shortcut Slot - Slot List Type
Select: Range
We’ll display a range of slots, from a start index to an end index. - Shortcut List Index
Set to: -1 - Slot Start Index
Set to: 1 - Slot End Index
Set to: 9
I’m displaying slots 1-9, so 9 slots in total.
Portrait #
And as a last step for the HUD, we’ll adjust the position of the portrait.
Select the Portrait Content child object.
Rect Transform #
Select the middle left anchor preset
- Pivot
Set to: X=0, Y=0.5 - Pos X
Set to: 0 - Pos Y
Set to: 0
And that’s it, save the changes you’ve made to the HUD prefab.
The HUD should now look something like this:
Updating HUD Setup #
With the prefab ready, we can set up the HUD in the editor. We also need to disable using the Shortcut HUD if you’re using it.
We don’t need to turn off the Player Battle HUD, since it doesn’t display due to it’s display conditions anyway. We’d have to set the Show Battle HUD game state for that.
New Player HUD #
Open the ORK editor, navigate to UI > HUDs and add a new HUD.
Base Settings #
- Name
Set to: Player Real Time - HUD Type
Select: Combatant - Auto Display
Enable
Combatant Settings #
We’ll only display the HUD for the leader of the player group, i.e. the player combatant.
- Only Leaders
Enable - Player
Enable - Ally, Enemy
Disable
Unity UI #
- UI Layer
Select: HUD - HUD Prefab
Select: Player RT Battle HUD
Disabling Shortcut HUD #
Select the Shortcuts HUD.
- Auto Display
Disable
Save Changes #
We’ll do another test, don’t forget to save your changes by clicking on Save Settings at the bottom of the editor.
Testing #
Alright, we’ve changed another batch of things, let’s see how it plays now.
Hit play and test the real time battle.
Seems our hard work paid off, the battle is working, we have a HUD, actions are animated correctly.
However, there is one more thing that’s been following us through all these tests … the 2nd player group member (if you’ve set up player group spawning).
We’ll change this in 2 ways:
- we don’t spawn the other group member
- we allow changing the player
Also, there’s no game over when the player dies, we’ll change that as well.
We’ll continue in the next part of the real time mini-series.




