I have a 2D freeform directional blend tree, have horizontal and Vertical float values inserted. I just want them to be updated automatically when my character moves, I'm not moving the character using keyboard or Mouse I'm merely setting Destination for the character to go to
Just save last position and check direction every frame. For example:
public class AnimationDemo : MonoBehaviour
{
private Vector3 _lastPosition;
private void Awake()
{
_lastPosition = gameObject.transform.position;
}
private void Update()
{
var currentPosition = gameObject.transform.position;
var moveDirection = currentPosition - _lastPosition;
CalculateAnimation(moveDirection);
_lastPosition = currentPosition;
}
private void CalculateAnimation(Vector3 moveDirection)
{
//you have moveDirection to send in your animation system
}
}