[Dive Into AGMaker] Introduction to How AGMaker Handles Input Action Maps

Introduction

If you print all the Action Maps at runtime, you will find that AGM, in order to support multi-player controllers, creates several proxy Action Maps with the suffix _agm_<controller_id> for each user-created Action Map in the project settings. All the GameObject nodes that listen for movement and use input as conditions in VS scripts are versions with this special suffix.

Key Points

  1. Create a Node type node under GameObject and attach this script to it.
  2. When you press this input at runtime, you will find that both prints are triggered.
  3. If you use nodes like Input.parse_input_event or TouchScreenButton to manually simulate input emission, you need to decide whether to include the _agm_<controller_id> suffix yourself.
  4. The movement function of GameObject and input-related functions in VS only care about input actions with the agm special suffix.
  5. Example: If the original Action Map name is Left, the Action Map name concerned by the first local player is Left_agm_0, where 0 represents the controller_id of this player.
  6. The controller_id of a GameObject is the value of the variable named controller_id in its corresponding VariableSettings node.

Core

extends Node

func _input(event: InputEvent) -> void:
    var action_name = "my_action_name"
    # Godot
    if event.is_action_pressed(action_name):
        print(action_name + " pressed!")
    # Game Object Interested
    var controller_id = 0
    var agm_listen = action_name + "_agm_" + str(controller_id)
    if event.is_action_pressed(agm_listen):
        print(agm_listen + " pressed!")
「いいね!」 1