Ah, now I see the issue. You can’t get the elapsed time directly from the input action. It comes from a struct holding instance data that you have to find through the enhanced input subsystem.
Try this:
float ADebugActorBase::GetElapsedSeconds(UInputAction* action)
{
auto enhancedInput = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(this->GetLocalPlayer());
if (enhancedInput)
{
auto playerInput = enhancedInput->GetPlayerInput();
if (playerInput)
{
auto actionData = playerInput->FindActionInstanceData(action);
if (actionData)
{
return actionData->GetElapsedTime();
}
}
}
return 0.f;
}
Add the action you want to check as a parameter. There are a lot of pointers to check, so if any of them fails, the function will just return 0.
I haven’t tested it in a game, so let me know if it works.