Assets -> Import Package -> Characters -> With the "All" selected -> Import


Behavior animaions for the Humanoid Character are imported to the "Assets/Standard Assets/Characters/ThirdPersonCharacter/Animation/" in the project window.

Right click in the Assets -> Create -> Foler -> rename to "Animators"


Right click in the Assets -> Create -> rename to "Animator Controller"


the above menu bar -> Windoow -> Animator
Animator window will be shown. "Layers" and "Parameter" can be switched between display and non-display. But if it is hided, let's switch to display.










Right click in the Animator window -> Make Transition -> Drag on to the "Walk" -> an arrow from "Idel" state to "Walk" is created.


From the "Parameter" in the Animator window, click "+", choose "Float", and type the name "MovingSpeed". The default value is 0.0 and it is ok for the initial value.




Select the transition arrow from the "Walk" state to "Idle" state in the Animator window by left clicking, and click "+" in the "Conditions" in the Inspector window. Specify the transition conditions as "MovingSpeed", "Less", "0.1".






Right click in the Assets/Scenes -> Create -> C# Script -> rename to "PlayerMoveAnim"

| PlayerMoveAnim.cs |
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMoveAnim : MonoBehaviour {
public float velocity = 1.3f;
private CharacterController charController;
private Animator animator;
void Start () {
charController = gameObject.GetComponent<CharacterController>();
animator = gameObject.GetComponent<Animator>();
}
void Update () {
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
Vector3 moveDirection = new Vector3(0, 0, 0);;
if (charController.isGrounded) {
moveDirection = new Vector3(h, 0, v);
}
float MovingSpeed = velocity * moveDirection.magnitude;
if (MovingSpeed > 0.1f) {
animator.SetFloat("MovingSpeed", MovingSpeed);
} else {
animator.SetFloat("MovingSpeed", 0.0f);
}
transform.LookAt(transform.position + moveDirection);
moveDirection.y += Physics.gravity.y;
charController.Move(velocity * Time.deltaTime * moveDirection);
}
}
|


to execute."AsianBoy" moves with the keyboard arrow keys (↑, ↓, ←, →) or the 'w', 'a', 's', 'd' keys. You can see that animation of the Humanoid Character switches according to the state. However, switching of behavior seems to be somewhat slow.



We already created the "PlayerMoveAnim.unity" scene, so overwrite it.
File -> Save Scenes