In this tutorial we’ll set up the first battle of the game.
This tutorial continues the sub-series for setting up battles.
It is finally time to add our first battle to the game. We’ll set up a single, non-repeatable battle using a Battle component.
Learn more about the different ways to add battles to your scenes in this documentation.
Adding the Battle #
Open the World scene (Assets/Scenes/) if you don’t have it open already.
You can either use the scene hierarchy context menu (ORK Framework > Battle > Battle (3D)) or the Makinom scene wizard (Create Game Object > Battle (3D)) to create a ready-to-use battle. It’ll add a new game object with a Battle component and a Sphere Collider (uses as trigger) attached. The battle starts when the player enters the trigger.
Add the battle a short distance away from the bridge outside of town.
Battle Component #
Let’s take a look at the Battle component’s setup in the inspector.
We’ll use a scene ID to remember if this battle was already finished or not – this works the same as with Item Collectors.
- Use Scene ID
Enable this setting.
The scene ID is already set to 0, since this is the first battle added to the scene.
Battle Settings #
Since this is the first battle of the game, we want the player to not be able to escape from it.
- Can Escape
Disable this setting.
The rest of the battle settings are usually not used very often, unless you want to override something, e.g. using a different battle system or battle start/end schematic.
Combatant Settings #
This is where you can add combatants or combatant groups that’ll be part of the battle.
There’s already a combatant added, so let’s set it up correctly.
- Faction
Select Enemies.
It’s crucial to use a faction that is an enemy of the player, otherwise the battle won’t start. - Use Group
Disable this setting.
We’ll use a defined, single combatant. - Combatant
Select Wasp.
You can leave the rest of the settings as they are.
Don’t forget to save the scene.
Testing #
Hit play and test your first battle – run out of town and along the road until you enter the battle’s trigger.
Allright – everything seems to be working!
The battle starts, camera zooms in, actions animate – great!
I’d adjust the rotation of the battle a bit, though.
Transform (Battle) #
- Rotation
Set to X=0, Y=-135, Z=0.
Hit play and test again.
Much better.
For future references – since the player spots are placed at positive Z axis and the enemy at negative Z axis in the battle’s local space, you can determine how combatants are placed based on the blue arrow of the game object:
The player will be placed in the direction of the blue arrow, the enemy in the other direction.
Getting the gang back together #
Let’s make things a bit easier and allow us to test more actions. We’ll adjust our start game schematic, adding the rest of the player combatants to the player group.
Open the StartGame schematic, e.g. by double clicking on it.
Duplicate the Join Group node 5 times and change their Combatant setting. Don’t forget to connect them with the other nodes.
The first 3 combatants you join to the player grup will be part of the initial battle group, participating in battles. You can switch them with the others using Switch in the battle menu.
Join Group (2) #
- Combatant
Select Rogue.
Join Group (3) #
- Combatant
Select Cleric.
Join Group (4) #
- Combatant
Select Ranger.
Join Group (5) #
- Combatant
Select Wizard.
Join Group (6) #
- Combatant
Select Monk.
Save the changes by clicking on Save Schematic.
Testing Again #
Hit play again and run to the first battle.
Now the tides have turned!
You’ll notice that suddenly the rogue has the first action isntead of the wasp, as he’s faster.
That’s it for our first battle.
Next, we’ll set up a simple move AI to allow enemies to hunt the player.