Animation Blueprint getting wrong values when changing player.

Hey guys I’m having some trouble with animation blueprints.

Basically, in my game, the player can swith between 4 characters.

When the characters spawn, they store a reference to their AI controller

when I change player, the current player gets its stored AI controller to possess it and the player control possesses the new player.

That all works fine, but I’m noticing some bugs with animation blueprint.

I managed to fix one already. Other bug:

If I crouch a character, then select another player, when I come back to this character he will stand up automatically.

Any ideas whats happening?


void AMainPlayerController::Crouch()
{
ACharacterBase* ControlledPawn = GetPawn<ACharacterBase>();

if (ControlledPawn)
{
if (ControlledPawn->bIsCrouched)
{
ControlledPawn->UnCrouch();
ControlledPawn->IsProne = false;
}
else
{
ControlledPawn->Crouch();
ControlledPawn->IsProne = false;
ControlledPawn->GetCharacterMovement()->MaxWalkSpeed = CachedMaxWalkSpeed;
}
}
}

Again, a rather hacky fix for something I feel should have just worked. I created a seperate variable on the character itself, which will be updated along with the crouch/uncrouch functions. Which is working
Seems like the anim blueprint doesnt keep up with the movement component, or the other way around

Solved

Decided the best course of action was to just disregard the built in crouch functionality altogether.
I’ve instead created a stance enum. Standing, Crouched, Prone.
character has a ChangeStance function and that function will handle any stuff like capsule adjustments etc.
It’s also made the anim blueprint transitions for readable too