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
- Create a Node type node under GameObject and attach this script to it.
- When you press this input at runtime, you will find that both prints are triggered.
- If you use nodes like
Input.parse_input_eventorTouchScreenButtonto manually simulate input emission, you need to decide whether to include the_agm_<controller_id>suffix yourself. - The movement function of GameObject and input-related functions in VS only care about input actions with the agm special suffix.
- Example: If the original Action Map name is
Left, the Action Map name concerned by the first local player isLeft_agm_0, where 0 represents thecontroller_idof this player. - The
controller_idof a GameObject is the value of the variable namedcontroller_idin 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!")