04 Player Attacks

In this tutorial we’ll set up the player’s attacks.

The player will have 4 base attacks to cycle through – each attack (beside the first) is only available for a short time before the attack resets to the first. The attack is set up with a single ability with 4 levels.

We’ll set up:

  • 4 schematics animating the attacks
  • ability of the attack
  • control map for using the attack
  • updating the player combatant

Additionally, attacks can be canceled when being attacked while using them, so we need to keep a few things in mind for this.

Let’s get to it!

Attack Schematic #

We’ll start with the first attack’s schematic – the attack’s user is the Machine Object. All attacks will have the same setup with slight variations (e.g. different wait times or animation to play), so we only have to set this up once and can handle the rest with copies of the same schematic.

As said, attacks can be canceled, so we need to ensure that certain nodes are executed in any case. This is done by enabling their Execute On Stop setting (at the top of the node’s settings). I’ll note in each node that needs this.

Navigate to Schematics and start working on a new schematic

Change Game State #

Add Node > Game > Game > Change Game State

We’ll first activate the Show Staff game state to show the staff.

Click on Add Game State.

  • Game State
    Select Show Staff.
  • Set State
    Select Active.

Wait #

Add Node > Base > Wait

We’ll wait for a frame (0 seconds) to give the staff time to show up.

  • Time
    Select Value > Value.
    Set to 0.

Play Sound #

Add Node > Audio > Audio > Play Sound

We’ll play a sound effect when swinging the staff. This’ll use a different sound effect for each attack.

  • Object (Play On)
    Select Machin Object.
    All game objects we’ll play sounds on already have an Audio Source set up on them, using Spatial Blend for 3D audio.
    We could also handle this setup here, but it’s better to have it already ready on the prefabs/game objects you’re using.
  • Audio Clip Asset
    Select swoosh01.
  • Play One Shot
    Enable this setting.
  • Set Pitch
    Enable this setting.
  • Random Pitch
    Enable this setting.
    This allows us to randomize the pitch of the sound, making it a bit different each time.
  • Pitch
    Set to 0.8.
  • Pitch 2
    Set to 1.2.

Activate Damage Dealer #

Add Node > Battle > Action Outcome > Activate Damage Dealer

This node is used to activate (and optionally set the action) of a damage dealer. We’ll use it to activate the damage dealers on the player (i.e. the weapon).

Remember, the weapon’s damage dealer is activated by a tag – we’ll set this tag in the attack ability, so we’ll use the ability information for the damage dealer’s activation. The schematic being used by the ability will automatically have this information available.

  • Object (Activate On)
    Select Machine Object.
  • Activate
    Enable this setting.
  • Use Action Tags
    Enable this setting.
    This’ll use the activation tags of the ability (or item) using this schematic.
  • Set Action
    Enable this setting.
    The damage dealer needs an action to activate, either already set before or now by this node.

Combatant Animation #

Add Node > Animation > Combatant > Combatant Animation

This node is used to play an animation type on a combatant.

  • Object
    Select Machine Object.
  • Animation Type
    Select Attack.
  • Wait
    Enable this setting.
  • Normalized Time
    Set to 0.4.
    We’ll wait for 40% of the animation’s duration.
  • Store Duration
    Enable this setting.
    We’ll store the duration into a variable to be able to wait at a later time based on the animation duration.
  • Normalized Time
    Set to 0.4.
    We’ll also store 40% of the duration.
  • Variable Key
    Set to wait.
  • Variable Origin
    Select Local.

Activate Damage Dealer #

Copy the previous Activate Damage Dealer node, we’ll now deactivate it again.

This node needs to be executed on stop.

  • Execute On Stop
    Enable this setting.
  • Activate
    Disable this setting.

Wait #

Add Node > Base > Wait

We’ll now wait for the stored duration

  • Time
    Select Variable > Float Variable.
  • Variable Key
    Set to wait.
  • Variable Origin
    Select Local.

Change Game State #

Copy the previous Change Game State node, we’ll now deactivate the Show Staff game state.

This node needs to be executed on stop.

  • Execute On Stop
    Enable this setting.
  • Set State
    Select Inactive.

And that’s it for the schematic. Click on Save Schematic to save it, e.g. as EllenAttack.

Attack 2 Schematic #

As said, the other attack schematics have the same setup, so we’ll continue working on this schematic.

We’ll simply change what we need to for this variation and use Save Schematic As to save it as a new schematic.

Play Sound #

We’ll play a different audio clip.

  • Audio Clip Asset
    Select swoosh02.

Combatant Animation #

We’ll play a different animation type and adjust the wait time.

  • Animation Type
    Select Attack 2.
  • Normalized Time (Wait)
    Set to 0.3.

And that’s it for the schematic. Click on Save Schematic As … to save it, e.g. as EllenAttack2.

Attack 3 Schematic #

Again, we’ll change what we need to for this variation and use Save Schematic As to save it as a new schematic.

Play Sound #

We’ll play a different audio clip again.

  • Audio Clip Asset
    Select swoosh03.

Combatant Animation #

We’ll play a different animation type and adjust the wait time and store duration.

  • Animation Type
    Select Attack 3.
  • Normalized Time (Wait)
    Set to 0.5.
  • Normalized Time (Store Duration)
    Set to 0.3.

And that’s it for the schematic. Click on Save Schematic As … to save it, e.g. as EllenAttack3.

Attack 4 Schematic #

For the last attack, we only adjust the Combatant Animation node and keep playing the same sound.

We’ll change what we need to for this variation and use Save Schematic As to save it as a new schematic.

Combatant Animation #

We’ll only play a different animation type.

  • Animation Type
    Select Attack 4.

And that’s it for the schematic. Click on Save Schematic As … to save it, e.g. as EllenAttack4.

Damage Dealer Hit Schematic #

With Ellen’s attack schematics done, we’ll set up one more schematic.

We’ll use a schematic to handle what happens when a damage dealer hits a damage zone. When not using a schematic, the damage dealer will directly deal the damage and optionally use a sound and prefab for effects.

However, our combatant prefabs already have damage particle effects set up on their prefabs, so we’ll use a schematic to play them. Or, to be more precise, we’ll use a schematic to start a tagged machine on the hit target, which handles it for us. For now, we only set up the damage dealer hit schematic and do the rest at a later time.

Create a new schematic.

Calculate Action #

Add Node > Battle > Action Outcome > Calculate Action

When using a schematic animating a damage dealer hit, we also need to use this node to handle the actual calculation of the damage (at a time of our choosing).

No further setup needed here.

Play Sound #

Add Node > Audio > Audio > Play Sound

We’ll play the Damage sound type on the target that was hit (Starting Object).

  • Object (Play On)
    Select Starting Object.
  • Use Sound Type
    Enable this setting.
  • Sound Type
    Select Damage.
  • Play One Shot
    Enable this setting.
  • Set Pitch
    Enable this setting.
  • Random Pitch
    Enable this setting.
  • Pitch
    Set to 0.8.
  • Pitch 2
    Set to 1.2.

Start Tagged Machine #

Add Node > Machine > Start Tagged Machine

Tagged machines are used to start schematics on game objects via a matching tag. Learn more about them in this Makinom documentation.

We’ll later add tagged machines to our combatants to manage the hit particle effect.

  • Wait
    Disable this setting.
    We don’t need to wait for the machines to finish.

The Machine Object settings handle on which game object the tagged machine will start. We’ll start them on the Starting Object.

  • Object (Machine Object)
    Select Starting Object.

The Starting Object settings handle which game object is used as the starting object of the tagged machine’s schematic. We’ll start them on the Machine Object (i.e. the combatant who attacked).

  • Object (Starting Object)
    Select Machine Object.

Click on Add Tag to add a starting tag.

  • Tag
    Set to hitEffect.

And that’s it for the schematic. Click on Save Schematic to save it, e.g. as DamageDealerHit.

Ability Type #

Before we set up the attack ability, we’ll set the ability type’s Damage Type to correctly handle damage animations.

Navigate to Status > Ability Types and select the Default type.

  • Damage Type
    Select Default.

Attack Ability #

Now it’s time to set up the ability for our attack.

Navigate to Status > Abilities, we’ll change the Default ability.

  • Name
    Set to Attack.

Ability Settings #

  • Ability Type
    Select Default.
  • Useable In
    Select Both.

Use Settings #

We’ll set the attack to be cancelable – i.e. if an enemy attacks the user while using the ability, the ability will get canceled.

This only happens if the enemy’s attack is also set up to cancel the target’s action.

  • Cancelable
    Enable this setting.

Target Selection Settings #

The attack should hit enemies, but not target a specific one. We just want to swing around our staff without a care in the world.

  • Target Type
    Select Enemy.
    The ability will damage enemies.
  • Target Range
    Select None.
    The ability doesn’t require a target.

User Settings > Use Costs #

We’ll set up stamina costs, i.e. using the attack consumes stamina.

  • Auto Consume
    Select Always.
    The use costs will always be consumed at the start of the ability.

Status Changes #

Click on Add Status Change.

  • Change Type
    Select Status Value.
  • Status Value
    Select Stamina.
  • Operator
    Select Sub.
  • Change Value
    Select Value > Value.
    Set the value to 5.

Target Settings > Target Changes #

Click on Add Target Change.

  • Cancel Action
    Enable this setting.
    The ability can cancel the target’s action (if it’s cancelable).

Click on Add Status Change.

  • Change Type
    Select Status Value.
  • Status Value
    Select HP.
  • Operator
    Select Sub.
  • Change Value
    Select Combatant > Status Value.
    We’ll directly use a status value of the user to deal damage, no need for formulas.
  • Status Value (Change Value)
    Select ATK.

Battle Animation #

Click on Add Battle Animation.

  • Schematic Asset
    Select EllenAttack.

Damage Dealer Settings #

Click on Add Tag.

  • Tag
    Set to weapon.

This is the same activation tag we’ve used on the staff’s damage dealer.

Click on Add Battle Animation. We’ll use the schematic we’ve set up to animate the damage dealer hit.

  • Schematic Asset
    Select DamageDealerHit.

We’ve now set up the first level for the attack – the other 3 levels are set up a lot faster, since we only need to adjust a few things.

Level 2 #

Scroll back up to the Level Settings.

Click on Copy Level.

You can also change between levels, add, copy and remove levels using the level buttons in the search bar (above the settings).

Use Settings #

We’ll set up the time the attack will be available during our base attack cycle.

  • Available Time
    Set to 0.5.

User Settings > Use Costs > Status Changes > Status Change 0 #

We’ll adjust the stamina cost.

  • Change Value
    Select Value > Value.
    Set the value to 8.

Target Settings > Target Changes > Target Change 0 > Status Change 0 #

We’ll increase the efficiency of the damage, dealing a bit more damage.

  • Efficiency
    Select Value > Value.
    Set the value to 1.2.

Battle Animation > Battle Animation 0 #

  • Schematic Asset
    Select EllenAttack2.

Level 3 #

Copy level 2.

Use Settings #

  • Available Time
    Set to 0.4.

User Settings > Use Costs > Status Changes > Status Change 0 #

  • Change Value
    Select Value > Value.
    Set the value to 12.

Target Settings > Target Changes > Target Change 0 > Status Change 0 #

  • Efficiency
    Select Value > Value.
    Set the value to 1.4.

Battle Animation > Battle Animation 0 #

  • Schematic Asset
    Select EllenAttack3.

Level 4 #

Copy level 3.

Use Settings #

  • Available Time
    Set to 0.3.

User Settings > Use Costs > Status Changes > Status Change 0 #

  • Change Value
    Select Value > Value.
    Set the value to 15.

Target Settings > Target Changes > Target Change 0 > Status Change 0 #

  • Efficiency
    Select Value > Value.
    Set the value to 1.6.

Battle Animation > Battle Animation 0 #

  • Schematic Asset
    Select EllenAttack4.

That’s it for the ability.

Control Map #

Next, we’ll set up the control map using the base attack.

Navigate to Base/Control > Control Maps, we’ll change the Default control map.

  • Field (Useable In)
    Enable this setting.
  • While Choosing
    Enable this setting.
    We’ll later use this to cancel out of the grenade throwing using it’s input key.

Control Key 0 #

Click on Add Control Key to add the first control key.

Input Settings #

  • Input Key
    Select Attack.

Action Settings #

  • Type
    Select Action.
    Uses an action.
  • Action
    Select Attack.
    Uses the combatant’s base attack.
  • Use Current Index
    Enable this setting.
    This’ll use the current base attack (for our cycling attacks).

Conditions #

  • During Target Selection
    Disable this setting.
    This’ll prevent us from using the base attack while selecting where to throw the grenade to.

Updating Ellen #

Now, we’ll update Ellen’s setup, adding the control map and base attack.

Navigate to Combatants > Combatants and select Ellen.

Base Settings > Control Maps #

Click on Add Control Map.

  • Control Map
    Select Default.

Attacks & Abilities > Override Settings > Base Attack #

  • Own Base Attack
    Enable this setting.
  • Action Stop Resets Index
    Enable this setting.
    This’ll reset the attack index back to the first attack in case a base attack was canceled.
    I.e. enemies can break the attack combo by attacking the palyer.

Click on Add Base Attack.

  • Ability
    Select Attack.
  • Ability Level
    Set to 1.

Copy Base Attack 0.

  • Ability Level
    Set to 2.

Copy Base Attack 1.

  • Ability Level
    Set to 3.

Copy Base Attack 2.

  • Ability Level
    Set to 4.

Save Changes #

And that’s it for the player’s attack!

Don’t forget to save your changes by clicking on Save Settings at the bottom of the editor.

Testing #

Hit play and swing your staff around using the attack input key (left mouse button).

You can cycle through 4 attacks, unless you wait too long (or run out of stamina).

 

Next, we’ll add something to hit, the first enemy!