I have never managed to bind a function that’s defined in another class other than one where I bind it. However, I did got a workaround for it. Define a function inside ACharacterPlayer that calls the function you actually want to call. For example, in your case, you would have something like:
void ACharacterPlayer::ThrowCable2_Redirect()
{
//call to the function you actually need, no matter where it is, eg.
myComponent->Test();
}
void ACharacterPlayer::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
{
//...
BindAction("ThrowCable2", IE_Pressed, this, &ACharacterPlayer::ThrowCable2_Redirect);
}
Sure you can, but you have to provide the appropriate object to call the function on as well. You pass “this” to BindAction as third parameter, but “this” is of type “ACharacterPlayer” in your case, not “UComponent” (which is where your function “Test” is located). That of course doesn’t work and hence you are getting the error. Also keep in mind that BindAction expects a function signature with no parameters and no return value. If you provide a function that does not match that signature you will also get an error.