In this tutorial we’ll set up some more schematics to animate battle actions.
Currently, our enemy’s game object is just destroyed when killed, and our player also shows no reaction on death. Like abilities, we can animate the death of a combatant using schematics – and that’s what we’ll do now.
We’ll also set up schematics to animate reviving (the player) and the use of items and non-physical attacks (spells, support).
We’ll set up 4 schematics:
- enemy death
- player death
- revive
- use (items/magic)
Let’s get to it.
Enemy Death Schematic #
We’ll start with the enemy’s death – it’ll play the Death sound type on the combatant, play the Death animation (in case we add one to enemies, otherwise this’ll just not play anything) and finally fade out the game object by changing the renderer’s color.
As usual, the user of the action (i.e. the dying combatant) is the Machine Object.
Open the Makinom editor and navigate to Schematics.
Play Sound #
Add Node > Audio > Audio > Play Sound
Play the Death sound type on the user.
- Object (Play On)
Select Machine Object. - Use Sound Type
Enable this setting. - Sound Type
Select Death. - Play One Shot
Enable this setting.
Combatant Animation #
Add Node > Animation > Combatant > Combatant Animation
We’ll play the Death animation on the user.
- Object
Select Machine Object. - Animation Type
Select Death.
Change Color #
Add Node > Animation > Fade > Change Color
We’ll fade the user’s game object to a black color without alpha (i.e. fully transparent).
- Color Type
Select Renderer. - Fade
Select Fade. - Wait
Enable this setting. - Time
Select Value > Value.
Set the value to 1. - Fade Alpha/Red/Green/Blue
Enable these settings. - Start Color
Set to a white color with full alpha (e.g. A=1 or A=255, depending on the color picker). - End Color
Set to a black color with no alpha (A=0). - Object (Game Object)
Select Machine Object. - Scope
Select All In Children.
And that’s it for the schematic. Click on Save Schematic to save it, e.g. as EnemyDeath.
Player Death Schematic #
The player’s death is animated nearly the same – just instead of fading out the game object at the end, we’ll wait for a bit.
We can just continue with the already set up schematic and save it as a new schematic at the end (using the Save Schematic As button).
Change Color #
Remove the Change Color node.
Wait #
Add Node > Base > Wait
We’ll wait for a second.
- Time
Select Value > Value.
Set the value to 1.
And that’s it for the schematic. Click on Save Schematic As to save it as a new schematic, e.g. as PlayerDeath.
Player Revive Schematic #
Reviving the player simply needs to stop the Death animation type from playing. We don’t have an extra revive animation in this tutorial series.
Create a new schematic.
Combatant Animation #
Add Node > Animation > Combatant > Combatant Animation
We’ll stop the Death animation on the user.
- Object
Select Machine Object. - Animation Type
Select Death. - Stop
Enable this setting.
Wait #
Add Node > Base > Wait
We’ll wait for a second.
- Time
Select Value > Value.
Set the value to 1.
And that’s it for the schematic. Click on Save Schematic to save it, e.g. as PlayerRevive.
Use Schematic #
And finally, we’ll set up a schematic to animate using something, e.g. an item or magic spell. We’ll play the Use animation, play an audio clip and spawn a prefab.
Create a new schematic.
Settings #
We’ll add a prefab and audio clip – like the prefab, audio clips added to the Settings node can be overridden by the actions using the schematic.
Prefabs #
Click on Add Prefab Resource.
- Auto Destroy After Time
Enable this setting. - Time
Set to 0.55. - Prefab
Select the Smoke prefab.
You can find it in Assets/Tutorial Assets/Prefabs/Effects/.
Audio Clips #
Click on Add Audio Clip Resource.
- Audio Cip
Select the Magic2 audio clip.
You can find it in Assets/Tutorial Assets/NinjaAdventure/Sounds/Game/.
Combatant Animation #
Add Node > Animation > Combatant > Combatant Animation
We’ll play the Use animation on the user.
Our use animation will set a bool parameter, playing until we stop it.
- Object
Select Machine Object. - Animation Type
Select Use.
Wait #
Add Node > Base > Wait
We’ll wait for a short time.
- Time
Select Value > Value.
Set the value to 0.2.
Play Sound #
Add Node > Audio > Audio > Play Sound
We’ll play the sound we added.
- Object (Play On)
Select Machine Object. - Audio Clip
Select Magic2. - Play One Shot
Enable this setting.
Spawn Prefab #
Add Node > Game Object > Prefab > Spawn Prefab
We’ll spawn the prefab on the target (Starting Object).
- Prefab
Select Prefab 0. - Target Type
Select Object. - Object (Target Object)
Select Starting Object.
Wait #
Add Node > Base > Wait
We’ll wait again.
- Time
Select Value > Value.
Set the value to 0.5.
Calculate Action #
Add Node > Battle > Action Outcome > Calculate Action
We now calculate the outcome of the action.
No further settings needed.
Wait #
Copy the previous Wait node, we just wait for another 0.5 seconds.
Combatant Animation #
Copy the first Combatant Animation node – we now stop playing the Use animation on the user.
Change the following setting.
- Stop
Enable this setting.
And that’s it for the schematic. Click on Save Schematic to save it, e.g. as Use.
Default Battle Animations #
Back to the default battle animations.
Navigate to Combatants > Combatants > General Settings.
Battle Settings > Default Battle Animations #
We’ll set up the death animations for player and enemies, and also use the Use animation to animate the defend command.
Defend Animation #
Click on Add Battle Animation.
- Schematic Asset
Select the Use schematic.
Death Animation #
We’ll use different setups for player and enemy combatants (as we already did for the ability/item start animations).
Click on Add Battle Animation.
- Schematic Asset
Select the PlayerDeath schematic. - Player/Ally
Enable these settings. - Enemy
Disable this setting.
Click on Add Battle Animation again, now it’s time for the enemy.
- Schematic Asset
Select the EnemyDeath schematic. - Player/Ally
Disable these settings. - Enemy
Enable this setting.
Save Changes #
And that’s it!
Save the changes using the Save Settings button at the bottom of the editor.
Testing #
Hit play and start a battle.
The enemy dies properly (so does the player), defend is animated – everything works.
Next, we’ll add some items.