BP input action overriding C++ code

So I have an input action that is defined in code for sprinting, and I want to do additional effects in BP. The problem is when I use that input action event in my BP, the code stuff doesn’t run anymore, so my character can no longer sprint. My setup in the BP is very simple: I connected the input action to a print string and that’s it. The strings print on the screen just fine, but my character no longer sprints. When I disconnect the input action, I can sprint just fine. Is this an intended feature or a bug?

1 Like

As far as the Blueprint overriding the code like that… I’m not sure if this is the intended behavior. As a workaround, you could just make the sprinting function in the code “BlueprintCallable” and stick it in the blueprint with the rest of your sprinting functionality from the input handle event node.

//  Sprint
UFUNCTION(BlueprintCallable, Category="MySprintFunctionCategory")
void MySprintFunction();

and then it will be exposed in the Blueprint.

1 Like

Yea, that was what I was thinking of doing, but I wanted to get an answer from Epic to make sure that I would need to use a workaround. Thanks for the tip though!

Have you tried right clicking on the function entry node and clicking the “Add Call To Parent Function” option? It seems to me that blueprints inherit from code (C++) classes, and so when you call a function in blueprint that is declared in code it overrides it, which is why your sprinting breaks. By adding a call to parent function you are running both the overriding code AND the overridden code.

Note: make sure that you put the call to the parent function at the correct spot in your blueprint logic (I’d recommend at the front if you’re trying to sprint and then add additional unrelated behavior like a print).

In case someone else looking for solution, now each blueprint’s input node has “Override Parent Binding” parameter in details section:

//tested at 4.26

1 Like

What is this in C++ code though? Is overriding the function with another bindAction create multiple instances of a key?

Is overriding the function with another bindAction create multiple instances of a key?

Iirc multiple InputComponent->BindAction() will make multiple subscriptions on input.

What is this in C++ code though?

BindAction() is a wrapper for AddActionBinding(), which accept FInputActionBinding as param, which have a bConsumeInput field that handle input consuming for current handler.
So you should to define your inputs via AddActionBinding() if you need this functionality