Setting multiple values through Input Axis

I’m trying to convert a blueprints project over to C++, and this was extremely simple to do in blueprints, but is apparently next-to-impossible in C++. Without getting too deep into the weeds, I have a complex movement system setup and part of how it all works is that the input axes run through a custom function that manages the different movement types. In order to work, it needs to know both the axis value and what direction the input binding is coming from. This is a trivial operation in blueprints, but I can’t find any equivalent method in C++, and it will quite literally make the code exponentially more complex if I can’t figure this out!t

Does anyone know how to pass multiple values to a function through an input axis in C++?

Here’s an example of the blueprint:

But you’re not passing multiple parameters through the input axis function in your BP, you’re still passing only Value, and Axis Direction doesn’t come from the Input Axis. I don’t see the full picture, of course, but to me it looks like:

PlayerInputComponent->BindAxis("MoveForward", this, &AMyCharacter::MoveForward);

void AMyCharacter::MoveForward(float Value)
{
    MovementDelegator(Value, FName("Forward"));
}

void AMyCharacter::MovementDelegator(float Value, FName AxisDirection)
{
// your code here
}

If you’ve seen this done with actions, you can do it with actions. Nothing’s stopping you from using the same keys for additional action inputs and handling your logic there based on pressed-released events.

Yeah, that’s the workaround I’m currently using. However, my game has eight different movement modes, and each one is going to interpret movement inputs differently. So this method ends up forcing me to create additional intermediate functions which serve no other purpose than to pass the input direction to the next function. It would dramatically reduce the bloat in my cpp and header file if I could do this all in one step. But it seems like this is not going to be an option for me.

I’ve seen examples where people have accomplished exactly what I’m aiming for with Input Actions (adding additional parameters to Input Bindings), but the syntax doesn’t work for Input Axes, because it seems the Input Axis framework is significantly different from how the engine handles Input Actions. Anyway, at this point I’ve already bitten the bullet and just gone ahead with accepting the extra intermediate functions and unnecessary added overhead. Would be nice to not have to do all that, though.

That’s worth considering!

I could create a separate Axis and Action binding for the same inputs, and try running something off of that… though I’m already sort of doing that for another function already. I may look into that though!