Some people ask me for this example. This is a very very very basic movement system:
Just forward-backward and right-left strafe. No rotation included.
.Import animations that actually moves around the space (AKA: root animated).
.The tricky part here is to setup the imported content. Check if your root animation is consistent. On my case, all animations have a small rotation over time so I've select "Bake Into Pose" on Root Transform Rotation so they don't rotate anymore.
. Create an animator and a state with a blend tree for your basic movement.
. Create two properties to deal with your blend tree. One for forward-backward and other to right-left strafe.
. Since we have several animations at the same direction, set your blend type to 2D Freeform Directional.
. Distribute your animations making your movement consistent. I like to use a very simple approach here being (0,0 - idle), (1,0- Run Right), (-1,0 - Run Left), (0,1- Run Forward), (0,-1 . Run Backward). Intermediary animations (Aka: Walking, Jogging...) take values between 0 and 1.
.I put this very simple script to change our Animator properties at our character.
.To handle Input I've used the Cross-Platform Input system so our Input can be easily adapted to Mobile Devices but there's tons of alternatives to handle Input, including just use the Built-In Input Class solution and be happy.
.I like to separate my Input from my character so I did this little script to deal with axial Input (Horizontal and Vertical) and pass to the script that is handle the animation. This scripts uses this simple extension for UnityEvent passing a Vector2 as parameter.
.At the end I've added a Cinemachine camera and a random object to be used as visual reference.