Moving to Target and Back

Create two schematics to move to the target of an attack and back.

In this tutorial we’ll create two simple schematics to animate battle actions. One for moving to the target of an attack, one for moving back to the user’s battle spot.

They can e.g. be used for a base attack, running to the target (1st schematic), attacking the target (other schematic) and moving back to the original position (2nd schematic).

Movement is handled using the Change Position node – the setup described here will use the Auto move component selection. This’ll try to select the appropriate component for movement, but this might not result in the desired outcome for all setups. If movement doesn’t work in your setup, try one of the different move components based on your setup (e.g. Character Controller).

Radius #

The Radius component can be used to define a radius on your combatants. This radius can be used to calculate distances, e.g. for this tutorial, the stop distance between user and target.

It’s highly recommended to use Radius components on the prefabs of your combatants.

The Radius component can be added via the components menu: Makinom > Scenes > Radius

Moving To Target #

This schematic will move the user of a battle action (e.g. an ability used as base attack) to the action’s target. The user is the Machine Object and the target is the Starting Object of the schematic.

You can download the finished schematic here:

Download Schematic

 

Change Position #

Add Node > Movement > Movement > Change Position

This node is used to set or move a game object to another position. We’ll use it to move the user to the target, based on the user’s run speed.

  • Moving Object
    Select Machine Object.
  • Move Component
    Select Auto.
    Please note that you might need to use a different selection based on your setup.

Target Position #

  • To Object
    Enable this setting.
  • Object
    Select Starting Object.

Movement Settings #

  • Move
    Enable this setting.
    We’ll move the combatant’s game object – when disabled, the node would set the position immediately.
  • Wait
    Enable this setting.
    The schematic will wait for the movement to finish.
  • Apply Gravity
    Enable this setting.
    Depending on your movement component setup, you might need to disable this.
  • Stop Distance
    Set to 0.
    We’ll run up directly to the combatant.
    The actual distance is also determined by the optional Radius components on your combatants.

We’ll also have the combatant look into the movement direction – please note that this is usually only used in 3D games, for most 2D games you don’t want to mess with the rotation.

  • Fade Direction
    Enable this setting.
    The combatant will look into the direction it moves.
    This is usually only used in 3D games.
  • Rotate Component
    Select Auto.
    Please note that you might need to use a different selection based on your setup.
  • Lock Rotation
    Enable X and Z.
    This is used to only rotate on your horizontal rotation axis, in 3D games that’d be the Y-axis, i.e. you want to block rotation on X/Z axes.

We’ll move based on the combatant’s Run speed (set up via the movement settings, either from the combatant general settings or the combatant’s individual settings).

  • Move By Speed
    Enable this setting.
  • Stop At Target
    Enable this setting.
  • Speed Type
    Select Run.
  • Speed
    Select Value > Value.
    Set the value to 5.
    This is used as a fallback move speed in case no run speed could be found.
  • Follow Position
    Enable this setting.
    In case the target moves, the user will keep following it’s new position.

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

Yes, the schematic only consists of a single node that handles all the work for us!

Move To Base #

This schematic will move the user of a battle action (e.g. an ability used as base attack) back to it’s battle spot.

You can download the finished schematic here:

Download Schematic

 

Settings #

We need to add an actor to be able to use the battle spot of the user (Machine Object).

Actors #

Click on Add Actor.

  • Actor Type
    Select User Base.

Change Position #

Add Node > Movement > Movement > Change Position

We’ll move the user back to it’s battle spot. This time, we’ll ignore the radius.

  • Moving Object
    Select Machine Object.
  • Move Component
    Select Auto.
    Please note that you might need to use a different selection based on your setup.

Target Position #

  • To Object
    Enable this setting.
  • Object
    Select Actor 0: User Base.

Movement Settings #

  • Move
    Enable this setting.
  • Wait
    Enable this setting.
  • Apply Gravity
    Enable this setting.
    Depending on your movement component setup, you might need to disable this.
  • Stop Distance
    Set to 0.
  • Ignore Radius
    Enable this setting.
    We want to stop on the battle spot’s position, so we need to ignore the radius of the combatant (optionally defined by it’s Radius component).

We’ll also have the combatant look into the movement direction – please note that this is usually only used in 3D games, for most 2D games you don’t want to mess with the rotation.

  • Fade Direction
    Enable this setting.
    The combatant will look into the direction it moves.
    This is usually only used in 3D games.
  • Rotate Component
    Select Auto.
    Please note that you might need to use a different selection based on your setup.
  • Lock Rotation
    Enable X and Z.
    This is used to only rotate on your horizontal rotation axis, in 3D games that’d be the Y-axis, i.e. you want to block rotation on X/Z axes.

We’ll move based on the combatant’s Run speed (set up via the movement settings, either from the combatant general settings or the combatant’s individual settings).

  • Move By Speed
    Enable this setting.
  • Stop At Target
    Enable this setting.
  • Speed Type
    Select Run.
  • Speed
    Select Value > Value.
    Set the value to 5.
    This is used as a fallback move speed in case no run speed could be found.
  • Follow Position
    Enable this setting.

Wait #

Add Node > Base > Wait

Add a short wait time to make sure the movement is done.

  • Time
    Select Value > Value.
    Set the value to 0.1.

Look At Enemies #

Add Node > Battle > Combatant > Look At Enemies

Reset the user’s rotation to look at it’s enemies.

  • Use Combatant
    Enable this setting.
    We’ll only change the rotation of the user, not all combatants.
  • Object
    Select Machine Object.

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

Using the Schematics #

The schematics are used to animate abilities or items in case you want to run up to a target to use the action.

E.g. to animate your base attack ability, navigate to Status > Abilities, select your attack ability and change the following settings.

Battle Animation #

Click on Add Battle Animation to add the schematic for moving to the target.

  • Schematic Asset
    Select the MoveToTarget schematic (or however you named it).
  • Auto Damage Dealers
    Disable this setting.
    In case you use auto damage dealers for dealing damage, you usually don’t want to activate them when running to the target (or back).

Add additional schematics to animate the actual attack (not covered by this tutorial).

Click on Add Battle Animation again to add the schematic for moving back to the battle spot.

  • Schematic Asset
    Select the MoveToBase schematic (or however you named it).
  • Auto Damage Dealers
    Disable this setting.

You can also limit using the schematics to defined battle systems or only use them for the player faction, etc.

In the end, your battle animation will probably have 3 schematics:

  • Battle Animation 0: Move To Target
  • Battle Animation 1: Attack (schematic handling animation, calculating damage, etc.)
  • Battle Animation 2: Move To Base

See this tutorial for an attack schematic setup example.

Alternative: One Step Forward, One Step Back #

You don’t want to run up to the target, but just make a step forward?

Sure – just replace use the Move Into Direction node, moving into the Forward and Back directions (no facing direction needed for this setup). Moving back can also use an additional Change Position node to set the combatant back on it’s battle spot, just to make sure moving forward and back constantly doesn’t move off track over time.

You can download example schematics here:

Download Schematic