UnityEngine.AnimatorStateInfo.IsTag C# (CSharp) Method

IsTag() public method

Does tag match the tag of the active state in the statemachine.

public IsTag ( string tag ) : bool
tag string
return bool
        public bool IsTag(string tag)
        {
            return (Animator.StringToHash(tag) == this.m_Tag);
        }

Usage Example

コード例 #1
0
    void FixedUpdate()
    {
        float h = Input.GetAxis("Horizontal");
        //float v = Input.GetAxis("Vertical");
        anim.SetFloat("Speed", h);							// set our animator's float parameter 'Speed' equal to the vertical input axis
        //anim.SetFloat("Direction", v);						// set our animator's float parameter 'Direction' equal to the horizontal input axis

        currentBaseState = anim.GetCurrentAnimatorStateInfo(0);

        if(currentBaseState.IsTag("Run"))
        {
            if(Input.GetButtonDown("Jump"))
            {
                anim.SetInteger("JumpType", UnityEngine.Random.Range(0,2));
                anim.SetBool("Jump", true);
            }

            if(Input.GetKeyDown (KeyCode.W))
            {
                //anim.SetInteger("JumpType", UnityEngine.Random.Range(0,3));
                anim.SetBool("JumpUp", true);
            }
        }

        else if(currentBaseState.IsTag("Jump") || currentBaseState.IsTag("Jumpup"))
        {
            if(!anim.IsInTransition(0))
            {
            anim.SetBool("Jump", false);
            anim.SetBool("JumpUp", false);
            }

        }
    }
All Usage Examples Of UnityEngine.AnimatorStateInfo::IsTag
AnimatorStateInfo