I am trying to use the input system within ECS systems but I hit a wall trying to handle performed events by actions. This is what I have so far:
public partial struct PlayerCombatSystem : ISystem, ISystemStartStop
{
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<InputManaged>();
}
public void OnStartRunning(ref SystemState state)
{
var input = SystemAPI.ManagedAPI.GetSingleton<InputManaged>().Value;
input.Gameplay.Attack.performed += Attack_performed;
}
private void Attack_performed(InputAction.CallbackContext obj)
{
Debug.Log("attack");
}
[BurstCompile]
public void OnStopRunning(ref SystemState state)
{
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
}
}
Since the Attack_performed function is called without a SystemState ref I can't really do a lot of stuff there, which makes the system kinda pointless. Is there a way that I can listen to events from the input system from the system Update method?
I feel like I am missing something from the input system that would allow me to do this, like reading a boolean that would be true during only one frame kinda like the old Input.GetKeyDown
