I have the following code inside my Pawn class’ SetupPlayerInputComponent()
InputComponent->BindAction("Grow", IE_Pressed, this, &AMyPawn::StartGrowing);
The StartGrowing function it calls is just a function that sets the bool bGrowing to true.
I have another function that sets the same bool (bGrowin) to false.
I don’t want to set it to false on IE_Released, I want to make it so if it’s true, the “Grow” key will set it to false, and if it’s false, it will set it to true.
For that I could simply make an if statement like so
if (!bGrowing)
InputComponent->BindAction("Grow", IE_Pressed, this, &AMyPawn::StartGrowing)
else
InputComponent->BindAction("Grow", IE_Pressed, this, &AMyPawn::StopGrowing)
(StopGrowing sets bGrowing to false)
But when I do it inside the
void AMyPawn::SetupPlayerInputComponent(class UInputComponent* InputComponent)
The code doesn’t do anything when I press the “Grow” key, as if the lines are being ignored because they’re inside an if statement.
Is there any way I can do this thing? Am I missing something?
Any help would be greatly appreciated.
Thanks in advance!