GetMoveDir() public method

public GetMoveDir ( ) : Vector3
return Vector3
Ejemplo n.º 1
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    protected virtual void HandleAnimation()
    {
        // NOTE: it is better performance to cache id at Awake/Start

        int id = Animator.StringToHash("Speed");

        animator.SetFloat(id, movementState.GetMoveSpeed());

        Vector3 curentDir = transform.forward;
        Vector3 wantedDir = movementState.GetMoveDir();
        float   angle     = Vector3.Angle(curentDir, wantedDir);
        Vector3 up        = Vector3.Cross(curentDir, wantedDir);

        angle *= Mathf.Sign(up.y);
        // exDebugHelper.ScreenPrint( "angle = " + angle );
        animator.SetFloat("Direction", angle / 90.0f, 0.1f, Time.deltaTime);

        //
        AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0);

        if (stateInfo.IsName("Base Layer.Jump"))
        {
            animator.SetBool("Jump", false);
        }
    }