Download

Feature Request: Allow return types in BindAction functions

Heya,

Say I have two classes, Base and Derived (Base derives from ACharacter). Base binds SomeVirtualFunction to some action input, and Derived overrides it. Now, it’d be awesome if I could do this:


bool bConsumedInput = Super::SomeVirtualFunction();
if(!bConsumedInput) { //do stuff }

My practical use case is having a SharedCharacter which is inherited by PlayerCharacter and MountCharacter. Only the former derivation can attack, but both can read signs, which is a higher priority (if a sign is in front of a player). I implement the sign reading in SharedCharacter, and I gotta check in my PlayerCharacter if any of that happened, before trigger my Attack action. Right now I do it via a protected placeholder bool, which feels a bit hacky. If we could have return types on bind functions it’d make it much more elegant. I know the Android SDK (and probably many more) implement this feature. Thanks in advance!

Best regards,
Damir H.

I think the way to do it best would be to bind a non-virtual function in Base which calls a different virtual function that Base defines and Derived overrides. Then you can do whatever you like with your virtual functions without concern as to the limitations of the input binding system (which is not going to be able to be changed).

That’s still a bit of a hacky setup but less so than what I had. Thanks for the quick reply!