Hi, i want to do something like in MyCharacter.cpp
PlayerInputComponent->BindAction("DiscardWeapon", IE_Pressed, , Other , &AMyPlayerController::DiscardWeapon);
how to access and bind the function DiscardWeapon
form AMyPlayerController class?
Hi, i want to do something like in MyCharacter.cpp
PlayerInputComponent->BindAction("DiscardWeapon", IE_Pressed, , Other , &AMyPlayerController::DiscardWeapon);
how to access and bind the function DiscardWeapon
form AMyPlayerController class?
Hello Alexa.Ki, thank you for posting.
To gain the BindAction function in your custom class, if not inherited, you would need to include some references as described here.
This article also expands on how to properly leverage the BindAction function in c++
I hope this helps.
Thank you sir for the answer, I know how the input bindings works, but I want to access the function from another class directly in bindings to bind.
if I use this
instead of other
. I should bind the function from the current class in which the bindings are declared, but I want to access the function from another class directly under bindings.
another approach i can call the foreign function from controller class in another function in the character class and bind the function using, but this needs to declare an extra function to call the foreign function.
Include header with class definition?
Sir i already included and its not working, i want to directly call the function from another class in input action bindings.
To call a function from another class you need two things:
Nothing less, nothing more.
I can call a function from another class and this is not the quesiton, the question is how to call a function in BindAction from another class.
example: 1
this is working
MyCharacter.h
void DiscardWeapon();`
MyCharacter.cpp
PlayerInputComponent->BindAction("DiscardWeapon", IE_Pressed, , this, &AMyCharacter::DiscardWeapon);
example: 2
this needs to be achieved
MyController.h
void DiscardWeapon();`
MyCharacter.cpp
PlayerInputComponent->BindAction("DiscardWeapon", IE_Pressed, , /*OtehrActor*/, &AMyController::DiscardWeapon);
I want to achieve example 2.
This is nonsense.
If you want invoke APlayerController::DiscardWeapon
then you need pass APlayerController
pointer.
If you want invoke ASomeOtherObject::DiscardWeapon
then you need to pass ASomeOtherObject
pointer.
You can’t call APlayerController
class method with whatever-you-want pointer.
thank you Sir
for explaining this, you just solved my issue, Really appreciated )