Tutorial: “Getting Started with ACTION GAME MAKER from Zero” – Chapter 3

Adjusting the Attack and Hit Collisions

First, let’s resize the HitCollision, which is currently too large.
Also, since we’re using a Mega Man–style system, the player’s body itself doesn’t need an attack hitbox. (If we were creating melee attacks, we would keep it, but for this tutorial we won’t be adding melee combat.)
So, we’ll go ahead and remove the AttackArea2D entirely.

  1. Select HitCollision.

  2. Drag its corners to resize it so it’s just slightly larger than the wall collision box.

  3. Right-click AttackArea2D.

  4. At the bottom of the menu, select Delete.

  5. A confirmation window will appear asking if you want to delete AttackArea2D and its child node AttackCollision. Click OK to remove them.

Creating the “Take Damage” Script

When the player is hit by an enemy’s attack, they should transition to a “Take Damage” state.
In this state, the player will be unable to move for a short time, be knocked back slightly (opposite to their facing direction), and then, after a short delay, return to their previous state.

The question is: from which states should this transition occur?
Since the Player already has seven states, creating links from every single one would be tedious.
This is where the AnyState box comes in handy.

What is AnyState?

As the name suggests, AnyState means “from any state.”
Links created from AnyState will transition if their conditions are met, regardless of the current state.
Additionally, there is a special execution action called “TransferToAction”, which allows you to return to the state you were in before the transition, ignoring normal links.

This makes AnyState ideal for handling reactions like taking damage.


Creating the “Take Damage” State

In the “Take Damage” state, we’ll configure:

  • Movement is disabled.

  • Facing direction cannot be changed.

  • The player moves backward (opposite the facing direction).

  • After 0.2 seconds, they return to the previous state.

  1. Right-click the space to the right of AnyState and select Add State.

  2. Rename the new State001 to Take Damage.

  3. In the Select Animation field, select DamageTaken.

  4. Expand the Action Settings in the Inspector.

  5. Enable “Ignore Input” and “Ignore Facing Direction Change.”

    • This ensures the player cannot move or turn during the damage reaction.
  6. Click + Add Executable Action.

  7. Select MoveInDisplayDirection.

  8. Enable the Opposite Direction option, then click Add.

  9. Again, click + Add Executable Action.

  10. Select Wait.

  11. Set the Value field to 0.2 seconds (make sure to type with half-width numbers).

  12. Once more, click + Add Executable Action.

  13. Select TransferToAction and click Add.

  14. If the actions are ordered as above, the “Take Damage” state is complete.


Linking AnyState to “Take Damage”

Links from AnyState are made the same way as from any other state.

  1. Right-click AnyState and select Add Link.

  2. Connect it to the Take Damage state.

  3. In the Inspector, click + Add Condition.

  4. Choose ContactWithAttackArea.

  5. Enable Select All Sides, then click Add.

  6. Now, whenever the player collides with an enemy’s attack hitbox from any direction, they will transition to “Take Damage.”


Test the Setup

Run a test play to verify that the damage reaction works correctly.
When colliding with an enemy, the player should:

  • Become temporarily uncontrollable.

  • Flash (due to invincibility settings).

  • Be knocked back slightly.


Troubleshooting Checklist

  • Doesn’t flash → Check the invincibility settings in BaseSettings.

  • No damage reaction → Confirm the link condition is set correctly.

  • Reaction occurs but behaves incorrectly → Re-check the contents of the Take Damage state.

Review of Chapter 3

In this chapter, we learned the following:

  • Repeated practice in object creation by making various types of game objects

  • The concepts of Collision Layers and Collision Masks

  • Taking damage and invincibility

  • How to use AnyState

However, while we now have working attack and damage systems, the game still has some shortcomings: the screen feels small, there’s no sound, and there’s no game over.

As it stands, it doesn’t quite feel like a complete game.
In Chapter 4, we’ll work on making it function properly as a real game.