In this tutorial we’ll set up schematics to animate the start and end of our battles.
Our battles take place in a separate battle scene – i.e. we need to remember the scene and position the player was before loading into the battle scene, or we can’t return there after the battle.
Additionally, which battle scene is used depends on the scene the player is in, so we’ll use a string variable that’ll contain the battle scene (we’ll set the variable later in our scenes, not in the schematics here).
We’ll set up:
- game state
- camera position
- battle start schematic
- battle end schematic for victory (collecting loot)
- battle end schematic for lost (game over)
Since we don’t use escaping in this game, we don’t need to set up a separate battle end schematic for this battle outcome. Let’s get to it!
Game State #
We’ll begin with setting up a game state – we’ll use this later as a condition for displaying the player’s battle HUD. Our battle start/end schematics will change that game state, giving us exact control over when the HUD should be visible.
Game states are simple states that are either active or inactive. They can be used as conditions for other things and also be changed automatically. A new project already comes with some game states set up, e.g. to check if player controls are blocked. Learn more about game states in this Makinom documentation.
Open the Makinom editor, navigate to Game > Game States and add a new game state.
- Name
Set to: Show Battle HUD - Initial State
Disable this setting.
Camera Position #
Camera positions are used to change a camera’s position, rotation or field of view based on a target, e.g. showing the front of a game object. We’ll use one to zoom in at the start of a battle, before transitioning to the battle scene.
Beside using the Makinom editor, you can also create camera positions using the scene wizard via a camera and a game object in your scene.
Navigate to Game > Camera Positions, we’ll change the Default position.
0: Battle Intro Zoom #
We’ll use this camera position in a battle start schematic to zoom in (high field of view) and do a camera spin.
Camera Settings #
- Name
Set to: Battle Intro Zoom
Position #
- Set Position
Enable this setting. - Position Offset
Set to X=0, Y=0, Z=0.
We’ll zoom in directly on the target’s position.
Rotation #
- Set Rotation
Enable this setting - Rotation
Set to X=0, Y=0, Z=180.
We’ll spin the camera on the Z-axis. - Look At
Enable this setting. - Ignore Rotation
Enable the Z axis.
When using Look At, this’ll ignore the look rotation on the Z-axis and use the defined rotation.
Field of View #
- Set Field of View
Enable this setting. - Field of View
Set to 150.
Save Changes #
That’s it for now in the regular editor – before changing to Schematics we need to save our changes.
Save the changes using the Save Settings button at the bottom of the editor.
Battle Start Schematic #
Now, we’ll set up the schematic animating our battle start.
We’ll remember the currently playing music (including it’s track position), the scene and position of the player and use the camera position to zoom in before loading into the battle scene.
Navigate to Schematics.
Settings #
We’ll block player/camera controls during the start schematic.
- Block Player Control
Enable this setting - Block Camera Control
Enable this setting.
Actors #
We’ll add an actor to have access to the Battle Arena – we’ll use it to focus the camera on the battle instead of the player.
Click on Add Actor.
- Actor Type
Select Battle Arena.
This’ll automatically use a currently ongoing battle’s game object.
Store Music #
Add Node > Audio > Music > Store Music
We store the currently playing music to be able to resume playing it after the battle (i.e. in a battle end schematic).
The default setup of the node should usually already be what we need. Please note that this depends on which music channel your music is playing on.
- Music Channel
Set to 0. - Store ID
Set to 0.
Play Sound (Channel) #
Add Node > Audio > Audio > Play Sound (Channel)
This node plays a sound on a sound channel instead of a game object in the scene.
- Audio Clip
Select Select Audio Clip.
This’ll let us directly define an audio clip in the node instead of setting one up in the Settings node. - Audio Clip Asset
Select the synthetic_explosion_1 audio clip.
You can find it in Assets/Tutorial Assets/Audio/Sounds/other/. - Sound Channel
Set to 0. - Wait
Disable this setting. - Play One Shot
Enable this setting.
Store Scene #
Add Node > Game > Scene > Store Scene
Stores the current scene and player position.
No further settings needed.
Change Camera Position #
Add Node > Game Object > Camera > Change Camera Position
Now we’ll zoom in by fading to the camera position.
- Camera Position
Select Battle Intro Zoom. - Object (Target Object)
Select Player. - Fade Position
Enable this setting. - Time
Select Value > Value.
Set the value to 1. - Wait
Disable this setting.
We don’t wait for the fade to complete and instead continue immediately with the next node. - Interpolation
Select Quadratic > Quadratic In.
Wait #
Add Node > Base > Wait
We’ll wait for a part of the zoom in before loading into the battle scene.
- Time
Select Value > Value.
Set the value to 0.5.
Load Scene #
Add Node > Game > Scene > Load Scene
Now we’ll load the scene the battle should take place in.
As said above, we’ll use the value of a string variable to hold the scene name.
- Spawn Machine Object
Enable this setting.
This will place the machine’s game object instead of the player – in this case, this’ll place the battle game object.
Target Scene 0 #
The Target Scene settings define the scene that will be loaded and where to spawn the machine (e.g. via spawn point).
- Target Scene
Select Variable > String Variable (in the popup field on the right side of the setting).
Set the text to: battleScene - Variable Origin
Select Global.
We’ll have the scene’s name stored in a global string variable, i.e. it’s available everywhere. - Position Type
Select Spawn ID.
This’ll use a Spawn Point in the loaded scene to place the battle. - Spawn ID
Select Value > Value.
Set the value to 0.
That’s the ID of the spawn point we already set up in the battle scenes.
Screen Fade Settings #
We handle fading out the screen here.
- Own Screen Fade
Enable this setting.
If disabled, the scene change will use the default screen fade setup (defined in Game > Game Settings).
We’ll use the Screen Fade Out settings – we can stick with the default setup:
- Fade Out
Enable this setting. - Time
Set to 0.5. - Interpolation
Select Linear. - Fade Alpha/Red/Green/Blue
Enable these settings. - Start Color
Set to a black color with no alpha (A=0). - End Color
Set to a black color with full alpha (A=1 or A=255, depending on the color picker).
We don’t use the Screen Fade In settings, we’ll fade in later after handling some other things.
- Fade In
Disable this setting.
Place At Spots #
Add Node > Battle > Spawn > Place At Spots
This’ll place the already spawned combatants at their battle spots.
This is probably not needed in a this battle start schematic since no spawned combatants should be there – but it doesn’t hurt to have it.
- Place All
Enable this setting.
Spawn Battle Combatants #
Add Node > Battle > Spawn > Spawn Battle Combatants
This’ll spawn all combatants participating in battle.
- Spawn All
Enable this setting.
Change Music #
Add Node > Audio > Music > Change Music
Now we change the music to our battle music.
- Music Channel
Set to 0. - Play Type
Select Play. - Music Clip
Select Battle.
Change Game State #
Add Node > Game > Game > Change Game State
We’ll activate our new game states to show the battle HUD (which we’ll set up later).
Click on Add Game State.
- Game State
Select Show Battle HUD. - Set State
Select Active.
Block Camera Control #
Add Node > Input > Block Camera Control
We’ll now unblock the camera control – we need to do this before we set the camera’s target, and also give the camera control time to update before fading in the screen.
- Block/Unblock
Disable this setting.
I.e. the camera control will be unblocked.
Camera Control Target #
Add Node > Input > Camera Control Target
This node changes the current target of the camera control. We’ll target the Battle Arena actor.
Please note that this only works for the built-in controls or custom controls that are based on them.
- Target Type
Select Game Object. - Object (Target Object)
Select Actor 0: Battle Arena.
Fade Screen #
Add Node > Animation > Fade > Fade Screen
And finally, we’ll fade in the screen.
- Wait
Enable this setting. - Time
Set to 0.5. - Interpolation
Select Linear. - Fade Alpha/Red/Green/Blue
Enable these settings.
Click on Swap Colors, that’ll exchange the start and end color, which should now go from full alpha to no alpha.
- Start Color
Set to a black color with full alpha (A=1 or A=255, depending on the color picker). - End Color
Set to a black color with no alpha (A=0).
And that’s it for the schematic. Click on Save Schematic to save it, e.g. as BattleStart.
Victory Schematic #
This battle end schematic is used when the player won the battle. We’ll play the victory music, collect our loot and return to the stored scene.
Create a new schematic.
Settings #
- Block Player Control
Enable this setting - Block Camera Control
Enable this setting.
Change Music #
Add Node > Audio > Music > Change Music
Play the victory music.
- Play Type
Select Play. - Music Clip
Select Victory.
Wait #
Add Node > Base > Wait
Wait a second.
- Time
Select Value > Value.
Set the value to 1.
Collect Battle Gains #
Add Node > Battle > Gains > Collect Battle Gains
This node is used to collect experience and loot from a battle – we’ll also display the loot dialogue.
- Show Gains
Enable this setting. - Collect Loot
Enable this setting. - Collect Experience
Enable this setting. - Wait
Enable this setting.
Wait #
Add Node > Base > Wait
We’ll wait a short time before returning to the stored scene.
- Time
Select Value > Value.
Set the value to 0.5.
Change Music #
Add Node > Audio > Music > Change Music
Now we’ll fade back to the stored music (we stored it in the battle start schematic).
- Play Type
Select Fade To. - Play Stored Music
Enable this setting. - Fade Time
Set to 1. - Interpolation
Select Linear.
Change Game State #
Add Node > Game > Game > Change Game State
We’ll inactivate the new game state to hide the HUD again.
Click on Add Game State.
- Game State
Select Show Battle HUD. - Set State
Select Inactive.
Load Scene #
Add Node > Game > Scene > Load Scene
We’ll load the scene that was previously stored.
- Spawn Machine Object
Disable this setting.
This time we spawn the player (the battle start schematic used this option to spawn the battle). - Scene Origin
Select Stored. - Own Screen Fade
Disable the setting.
We’ll just use the default screen fade settings (defined in Game > Game Settings).
And that’s it for the schematic. Click on Save Schematic to save it, e.g. as BattleEndVictory.
Defeat Schematic #
This battle end schematic is used when the player lost the battle. We’ll play the lost music and call game over.
Create a new schematic.
Settings #
- Block Player Control
Enable this setting - Block Camera Control
Enable this setting.
Change Music #
Add Node > Audio > Music > Change Music
Play the victory music.
- Play Type
Select Fade Out Play. - Music Clip
Select Lost. - Fade Time
Set to 1. - Interpolation
Set to Linear.
Change Game State #
Add Node > Game > Game > Change Game State
We’ll inactivate the new game state to hide the HUD again.
Click on Add Game State.
- Game State
Select Show Battle HUD. - Set State
Select Inactive.
Wait #
Add Node > Base > Wait
We’ll wait for 3 seconds.
- Time
Select Value > Value.
Set the value to 3.
Game Over #
Add Node > Game > Game > Game Over
This node will call game over according to the Game Over Settings (in Game > Game Settings).
No further settings.
And that’s it for the schematic. Click on Save Schematic As … to save it, e.g. as BattleEndDefeat.
Using the Schematics #
With our battle start/end schematics set up, we’ll now return to our Turn Based battle system to use the schematics.
Navigate to Battles > Battle System and select the Turn Based battle system.
Base Settings > Battle Start/End Schematics #
We’ll use the schematics we’ve set up.
- Start Schematic
Select the BattleStart schematic. - Victory Schematic
Select the BattleEndVictory schematic. - Defeat Schematic
Select the BattleEndDefeat schematic.
Save Changes #
And that’s it!
Save the changes using the Save Settings button at the bottom of the editor.
Next, we’ll finally get to adding battles to our game.