Download

Variables invert on every 2nd key release (instead of 1st)

Hello, I am having a little problem and I can’t seem to figure out why this is happening. So, inside my Pawn class (BasePawn) I got 2 bool variables that need to invert their values on keyboard release (left shiftclick). I did link PlayerInputComponent->InputAction correctly, since it does print message on button release.

I am calling it inside BasePawn like this:

void ABasePawn::SetNextPlayer()
{
bIsRedPossessed = !bIsRedPossessed;
bIsBluePossessed = !bIsBluePossessed;
}

So, the values actually invert on every 2nd key release, these are the results:
1, 0 ---- should be ----> 1, 0
1, 0 ---- should be ----> 0, 1
0, 1 ---- should be ----> 1, 0
0, 1 ---- should be ----> 0, 1

Of, sorry, figured it out.

I have 2 child classes (RedPawn and BluePawn), they do inherit their parents properties but they have their own version of “bIsRedPossessed” and “bIsBluePossessed”. So it needs to update for each child class separately thus requiring double keyboard release.

Very new to programing and blueprints, couldn’t figure it out from morning and it was bugging me all day, sorry about this!