# What would be the best way to flag a sudden change in movement direction?

**URL:** <https://forums.unrealengine.com/t/what-would-be-the-best-way-to-flag-a-sudden-change-in-movement-direction/474648>\
**Category:** Character & Animation\
**Tags:** run-behavior, unreal-engine, question\
**Created:** [November 17, 2020, 11:43pm UTC](https://forums.unrealengine.com/t/what-would-be-the-best-way-to-flag-a-sudden-change-in-movement-direction/474648 "2020-11-17T23:43:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Re4verbot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Re4verbot](https://forums.unrealengine.com/u/Re4verbot)\
**Post date:** [November 17, 2020, 11:43pm UTC](https://forums.unrealengine.com/t/what-would-be-the-best-way-to-flag-a-sudden-change-in-movement-direction/474648/1 "2020-11-17T23:43:44Z")

</div>

I need some help in how to script this, or at least, the values I need to get to pull this off.

What I want to do is make it so that if the player is running forward and they decide all of a sudden to run backwards and move in the opposite direction, an animation will play of the character transitioning into that direction. I attached a still of the animation to help convey the idea.

 ![322382-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/5/b/a5b7ee1f8213e5b7577ebb75123e8bb77ffe02ea.png)

I was think of having an integer that counts up while the forward direction [W] is held up to say, 5. When the player releases the movement button, it slowly drops to zero. If the player is at a count of 3 or more holding [W] and quickly presses down back [S], the animation will play. My question is, what would be the most efficient way to pull off this sort of system?
