コード例 #1
0
    // triggers or toggles animations based on input
    // animations have events that trigger callbacks in this script, which I will mark
    void Update()
    {
        if (controllable)
        {
            if (Input.GetKey(KeyCode.LeftShift))
            {
                movement.multiplier = 2f;
                animator.SetFloat("movementMultiplier", 2);
            }
            else
            {
                movement.multiplier = 1f;
                animator.SetFloat("movementMultiplier", 1);
            }

            if (Input.GetKeyDown("e") || ActionInput.GetAction("LeftJab"))
            {
                animator.SetTrigger("PunchLeft");
            }
            else if (Input.GetKeyDown("r") || ActionInput.GetAction("RightJab"))
            {
                animator.SetTrigger("PunchRight");
            }
            else if (Input.GetKeyDown("f") || ActionInput.GetAction("RightHook"))
            {
                animator.SetTrigger("HookRight");
            }
            else if (Input.GetKeyDown("g") || ActionInput.GetAction("LeftHook"))
            {
                animator.SetTrigger("HookLeft");
            }
            else if (Input.GetKeyDown("q"))
            {
                animator.SetBool("Block", true);
                movement.multiplier = blockSpeedMultiplier;
                animator.SetFloat("movementMultiplier", blockSpeedMultiplier);
            }
            else if (Input.GetKeyUp("q"))
            {
                animator.SetBool("Block", false);
                movement.multiplier = 1f;
                animator.SetFloat("movementMultiplier", 1);
            }
        }
        IFrames = IFrames > 0 ? IFrames - 1 : 0;
    }