1.云彩左右飘动效果
public class SimpleMove : MonoBehaviour
{
    private Vector3 originPos;
    private Vector3 towardsPos;
    private Vector3 curTarget;
    private void Start()
    {
        originPos = transform.position;
        towardsPos = transform.position + new Vector3(3, 0, 0);
        curTarget = towardsPos;
    }
    private void Update()
    {
        if (Vector3.Distance(transform.position,curTarget)<0.1f)
        {
            //到了当前的tar
            if (curTarget == towardsPos)
            {
                curTarget = originPos;
            }
            else
            {
                curTarget = towardsPos;
            }
        }
        Vector3 forward = Vector3.Normalize(curTarget - transform.position) * Time.deltaTime;
        transform.position += forward;
    }
}
2.制作按钮-可拓展
public class MyButton : MonoBehaviour
{
    public bool isPressing = false;//一直按着按钮为true
    public bool onPressed = false;//按下按钮为true
    public bool onReleased = false;//松开按钮为true
    private bool curState = false;
    private bool lastState = false;
    public void Tick(bool input)
    {
        curState = input;
        isPressing = curState;
        onPressed = false;
        onReleased = false;
        if (curState != lastState)
        {
            if (curState)
            {
                onPressed = true;
            }
            else
            {
                onReleased = true;
            }
        }
        lastState = curState;
    }
}
3.用户输入
将用户的输入转换成虚拟信号
public class KeyAndCoardInput : MonoBehaviour
{
    [Header("===== Key Setting =====")]
    public string keyLeft = "a";
    public string keyRight = "d";
    public string keyJump = "space";
    public string keyAtk01;
    public string keyAtk02;
    [Header("===== Output signals =====")]
    public float Dright;
    public bool jump;
    public bool attack01;
    
    public MyButton buttonJ = new MyButton();
    public MyButton buttonSpace = new MyButton();
    // Update is called once per frame
    void Update()
    {
        buttonJ.Tick(Input.GetKey(keyAtk01));
        buttonSpace.Tick(Input.GetKey(keyJump));
        attack01 = buttonJ.onPressed;
        jump = buttonSpace.onPressed;
        //移动后期可以添加SmoothDamp处理
        Dright = ((Input.GetKey(keyRight) ? 1.0f : 0) - (Input.GetKey(keyLeft) ? 1.0f : 0));
    }
}
4.清空Trigger
在idle状态中AddBehavior,进入idle状态重置atk的trigger
public class FSMClearSignals : StateMachineBehaviour
{
    public string[] clearTriggerAtEnter;
    public string[] clearTriggerAtExit;
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        foreach (string item in clearTriggerAtEnter)
        {
            animator.ResetTrigger(item);
        }
    }
}