How to make animation starts when object moves?

So i am looking to make a game when the running animation runs when the character moves so how do i do it.

If you use buttons to control a player, for example, WASD, then you can monitor the status of these buttons, whether they are now pressed or not. If, for example, you press the W button, which forces the player to move forward, then you can play the corresponding animation using the play method. You can also add a condition when there are no button presses and, for example, play the swaying animation in place.