Hi,
currently I’m using the new Input System for my player controls. The actions are grouped into an actionmap, which I access via the auto-generated C# script’s namespace. In my player script, I enable and disable the actionmap - this works as expected:
private void OnEnable()
{
playerActionMap.Enable();
}
private void OnDisable()
{
playerActionMap.Disable();
}
Some of the controls are also being used in other scripts. A simple example can be seen below:
public class TestOnJumpButton : MonoBehaviour
{
private Controls controls;
private InputActionMap playerActionMap;
private void Awake()
{
controls = new Controls();
playerActionMap = controls.Player;
controls.Player.Jump.performed += ctx => TestOnInput();
}
private void OnEnable()
{
playerActionMap.Enable();
}
private void OnDisable()
{
playerActionMap.Disable();
}
private void TestOnInput()
{
Debug.Log("Pressed Jump Button");
}
Now my problem:
I would have expected, that if I enable / disable the actionmap in one script, it would globally enable / disable it for all scripts listening to its actions. But this does not work… The “TestOnJumpButton” script only works if I enable the actionmap in this script. Also, if I disable the Player Script (and therefore the actionmap with it) during runtime, the “TestOnInput()” function is still being called whenever the Jump action is activated.
Am I overlooking something? Is this intented behaviour?