Manual: Display Direction (DisplayDirection) and Gaze Direction (FaceDirection)

ACTION GAME MAKER includes a system called “Display Direction,” which plays animations corresponding to an object’s orientation for each state.
This manual explains how to control the display direction.

For the manual on animation sets that configure display direction, see: マニュアル: アニメーションセットの詳細設定

Overview of the Display Direction System

Display direction can be set in 8 directions.

Configuring Display Direction

Display direction can be changed via the “Display Direction” setting in each state.
Additionally, you can use the “Facing Direction” setting available in the FaceDirectionSettings node for more detailed control.

Configuring “Display Direction” for Each State

You can set the display direction to one of the following options:

  • Movement Direction: Always synchronized with the direction the object is moving.
  • Movement Key Direction: Always synchronized with the direction input via the object’s assigned movement keys.
  • Right/Left: Always faces either right or left.
  • Use FaceDirectionSettings: Faces the direction specified by the Facing Direction setting in the FaceDirectionSettings node (explained below).

The configured display direction is maintained while the object remains in the same state.

FaceDirectionSettings Node (Facing Direction Settings)

This node specifies the “Facing Direction.”
It functions when placed as a child of the object.
The following settings are available in FaceDirectionSettings:

  • Movement Direction: Always synchronized with the direction the object is moving.
  • Movement Key Direction: Always synchronized with the direction input via the object’s assigned movement keys.
  • Do Not Change (Free): Does not change the display direction until modified by an action or script.
  • Specified Object’s Direction: Faces the direction of the specified object.
  • Specified Group: Faces the direction of the nearest object belonging to the specified group.

Each setting in FaceDirectionSettings can also be modified using the execution action “Change Object Property (ChangeObjectProperty).”

Note: The facing direction (FaceDirection) is a separate variable from the display direction (DisplayDirection). However, as mentioned above, you can use the facing direction as the display direction by selecting “Use FaceDirectionSettings” in the display direction setting of each state.

Execution Action: “Change Facing Direction (ChangeFaceDirection)”

This action allows you to change the facing direction.
Note that this affects only the facing direction, not the display direction.
Therefore, if the state’s display direction setting is “Use FaceDirectionSettings” and FaceDirectionSettings is not set to “Do Not Change (Free),” any changes may be immediately overwritten. Please exercise caution.

In “Change Facing Direction (ChangeFaceDirection),” you can configure the direction as follows:

  • Angle: Specify direction in 360 degrees, with 0 degrees facing right.
  • Direction: Directly select from 8 directions.
  • Variable: Use the value of a variable as degrees to specify direction.
  • Movement Direction: Faces the current movement direction at execution time.
  • Specified Object: Faces the direction of the specified object.

Display Direction and Display Direction Variable (visible_direction)

The visible_direction variable displays the current facing direction in 45-degree increments:
Right: 0°, Down-Right: 45°, Down: 90°, etc.
This variable merely represents the current direction for convenience; assigning a value to it will not cause any change.
Therefore, to change the direction based on the current direction, follow these steps:

  1. Assign the visible_direction variable to another variable A.
  2. Add the desired angle value to variable A.
  3. Use the “Change Facing Direction (ChangeFaceDirection)” action to change the display direction based on the value of variable A.

Practical Examples of Display Direction

Mario-style Sliding Movement

Set the movement mode to “Acceleration” in MoveAndJumpSettings.
By setting the display direction to “Movement Key Direction,” you can achieve Mario-style movement, such as braking while facing the opposite direction.

Facing Any Stick Direction Without Movement

Achieve this using ChangeAngleSettings and “Face Direction of Specified Group”:

  1. Add a Node2D as a child of the GameObject and rename it “TargetRoot” for clarity.
  2. Add another Node2D as a child of the TargetRoot node and rename it “Target” for clarity.
  3. In the Target node’s Inspector, set its Transform position to x=100, y=0.
  4. Add a group with any name to the Target node.
  5. Add ChangeAngleSettings as a child of the GameObject.
  6. In the ChangeAngleSettings Inspector, enable “Use Right or Left Stick” and set TargetRoot as the target node.
  7. In FaceDirectionSettings, configure it to follow the group name assigned to the Target node. Done.

【Mechanism Explanation】
The ChangeAngleSettings node rotates the TargetRoot node according to the stick input.
Since the Target node is offset to the right from the origin of the TargetRoot node, rotating TargetRoot causes Target to rotate in a circular path.
FaceDirectionSettings follows the Target node’s circular motion, causing the object to face the stick’s direction.

Facing the Mouse Cursor Direction

First, create an object for the mouse cursor:

  1. Create a new game object. Use template: GDScrip_sample, type: SimpleCursor.
    SimpleCursor is a node with a script that always follows the mouse position.
  2. Save SimpleCursor and place it in the UI layer of the game scene. (Placing it in the default layer may cause issues due to offsets, etc.)
  3. In FaceDirectionSettings, set the target node to follow SimpleCursor.

【Note】
You can also achieve similar behavior by enabling “Use Mouse” in ChangeAngleSettings from the previous section, “Facing Any Stick Direction Without Movement.”