# Animation Blueprint getting wrong values when changing player.

**URL:** <https://forums.unrealengine.com/t/animation-blueprint-getting-wrong-values-when-changing-player/156382>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [January 15, 2021, 9:47am UTC](https://forums.unrealengine.com/t/animation-blueprint-getting-wrong-values-when-changing-player/156382 "2021-01-15T09:47:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cypher2012](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Cypher2012](https://forums.unrealengine.com/u/Cypher2012)\
**Post date:** [January 15, 2021, 9:47am UTC](https://forums.unrealengine.com/t/animation-blueprint-getting-wrong-values-when-changing-player/156382/1 "2021-01-15T09:47:27Z")

</div>

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?

```auto

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;
}
}
}

```

---

<div class="post-metadata">

**Author:** ![Cypher2012](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Cypher2012](https://forums.unrealengine.com/u/Cypher2012)\
**Post date:** [January 15, 2021, 10:55am UTC](https://forums.unrealengine.com/t/animation-blueprint-getting-wrong-values-when-changing-player/156382/2 "2021-01-15T10:55:23Z")

</div>

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

 ![HackMethod.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/e/d/ed8fae2c7a242afa71981097df2374a4502418b2.png)

---

<div class="post-metadata">

**Author:** ![Cypher2012](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Cypher2012](https://forums.unrealengine.com/u/Cypher2012)\
**Post date:** [January 15, 2021, 11:44am UTC](https://forums.unrealengine.com/t/animation-blueprint-getting-wrong-values-when-changing-player/156382/3 "2021-01-15T11:44:58Z")

</div>

Solved  
[![](https://static.xx.fbcdn.net/images/emoji.php/v9/t51/1/16/1f603.png) ](https://static.xx.fbcdn.net/images/emoji.php/v9/t51/1/16/1f603.png)

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  
[![](https://static.xx.fbcdn.net/images/emoji.php/v9/t4c/1/16/1f642.png) ](https://static.xx.fbcdn.net/images/emoji.php/v9/t4c/1/16/1f642.png)
