In ACTION GAME MAKER, each state is equipped with a system called DisplayDirection, which plays animations corresponding to the object’s facing direction.
This manual explains how to control DisplayDirection.
For information on animation sets that support DisplayDirection, please refer to:
Overview of the DisplayDirection System
DisplayDirection can be set to 8 directions.
How to Set DisplayDirection
DisplayDirection can be changed in the “DisplayDirection” setting of each state.
Additionally, more precise control can be achieved by using the FaceDirection set in the FaceDirectionSettings node.
“DisplayDirection” Settings in Each State
DisplayDirection can be selected from the following options:
- Movement Direction: Always synchronized with the current movement direction.
- Movement Key Direction: Always synchronized with the movement key input direction set for the object.
- Right / Left: Always faces right or left.
- Use FaceDirectionSettings: Determines direction based on the FaceDirection set in the FaceDirectionSettings node described below.
Once set, DisplayDirection remains unchanged during the same state.
FaceDirectionSettings Node (Face Direction Settings)
This node is used to specify the FaceDirection.
It becomes effective when placed as a child node of the object.
The following settings can be configured in FaceDirectionSettings:
- Movement Direction: Always synchronized with the current movement direction.
- Movement Key Direction: Always synchronized with the movement key input direction set for the object.
- Fixed (Free): Does not change the display direction until modified by an action or script.
- Target Object Direction: Faces the direction of the specified object.
- Target Group: Faces the direction of the nearest object in the specified group.
Settings in FaceDirectionSettings can also be modified using the action “ChangeObjectProperty”.
FaceDirection is an independent variable separate from DisplayDirection.
However, as mentioned above, you can use FaceDirection as the DisplayDirection in the DisplayDirection settings of each state.
Executing the Action “ChangeFaceDirection”
This action changes the FaceDirection.
Note that it does not directly change DisplayDirection, but only changes FaceDirection.
Therefore, if the state’s DisplayDirection is set to “Use FaceDirectionSettings” and FaceDirectionSettings is not set to “Fixed (Free)”, the change may be immediately overwritten—please be cautious.
In “ChangeFaceDirection”, the following settings can be configured:
- Angle: Specified in the range of 0°–360°, with 0° representing the right direction.
- Direction: Directly select from 8 directions.
- Variable: Specify direction using the value (angle) of a variable.
- Movement Direction: Faces the movement direction at the time of execution.
- Target Object: Faces the direction of the specified object.
DisplayDirection and the visible_direction Variable
The visible_direction variable represents the current facing direction in 45° increments.
For example:
- Right: 0°
- Down-right: 45°
- Down: 90°
This variable is only used for convenient representation of the current direction.
Assigning a value to this variable will not cause any change.
Therefore, if you wish to adjust the direction based on the current direction, follow these steps:
- Assign the visible_direction variable to another variable A.
- Add the desired angle value to variable A.
- Use the “ChangeFaceDirection” action to change the direction based on the value of variable A.
Examples of DisplayDirection Applications
Mario-style Sliding Movement
In MoveAndJumpSettings, set the movement mode to Acceleration,
and set DisplayDirection to Movement Key Direction.
This enables Mario-style movement where the character brakes while facing the opposite direction.
Facing Any Joystick Direction Without Moving
This can be achieved using ChangeAngleSettings and “Target Group”.
Steps:
- Add a Node2D under the GameObject and rename it to
TargetRoot. - Add another Node2D under
TargetRootand rename it toTarget. - In the Inspector → Transform of the
Targetnode, set the position to x = 100, y = 0. - Add any group name to the
Targetnode. - Add ChangeAngleSettings under the GameObject.
- In the Inspector of ChangeAngleSettings, enable Use Right Stick or Use Left Stick, and set the target node to
TargetRoot. - In FaceDirectionSettings, set it to track the group that the
Targetnode belongs to—this completes the setup.
Explanation of Mechanism
The ChangeAngleSettings node rotates the TargetRoot node based on joystick input.
Since the Target node is offset to the right relative to TargetRoot, it moves in a circular path when TargetRoot rotates.
FaceDirectionSettings tracks this circularly moving Target node, causing the object to face the joystick direction.
Facing the Mouse Cursor
First, create an object for the mouse cursor.
Steps:
- Create a new GameObject using the GDScript_sample template and select the type SimpleCursor.
SimpleCursor is a script node that always follows the mouse position. - Save SimpleCursor and place it on the UI layer of the game scene.
(Placing it on a regular layer may cause offset or other issues.) - In FaceDirectionSettings, set the target object to track SimpleCursor.
Additional Note
In the previous example, “Facing Any Joystick Direction Without Moving,”
you can achieve the same effect by enabling Use Mouse in ChangeAngleSettings.