Example #1
0
    public void StopAnimation(GameConstants.AnimDir dir)
    {
        switch (dir)
        {
        case (GameConstants.AnimDir.Up):
            this.GetComponent <Animator>().SetBool(_walkUp, false);
            break;

        case (GameConstants.AnimDir.Right):
            this.GetComponent <Animator>().SetBool(_walkRight, false);
            break;

        case (GameConstants.AnimDir.Left):
            this.GetComponent <Animator>().SetBool(_walkLeft, false);
            break;

        case (GameConstants.AnimDir.Down):
            this.GetComponent <Animator>().SetBool(_walkDown, false);
            break;

        default:
            //empty case
            break;
        }
        //Turn on root motion capability
        //this.GetComponent<Animator>().applyRootMotion=true;
    }
Example #2
0
    public void Move(Vector3 dir, GameConstants.AnimDir animDir)
    {
        //Turn off root motion in animator
        //this.GetComponent<Animator>().applyRootMotion = false;
        //Handle animation
        AnimateWalk(animDir);
        Vector3 currPos = this.gameObject.transform.position;
        Vector3 newPos  = currPos + dir * this._moveSpeed * Time.deltaTime;

        this.gameObject.transform.position = newPos;
    }
Example #3
0
    public void AnimateWalk(GameConstants.AnimDir dir)
    {
        switch (dir)
        {
        case (GameConstants.AnimDir.Up):
            this.GetComponent <Animator>().SetBool(_walkUp, true);
            //set other flags off
            this.GetComponent <Animator>().SetBool(_walkRight, false);
            this.GetComponent <Animator>().SetBool(_walkLeft, false);
            this.GetComponent <Animator>().SetBool(_walkDown, false);
            break;

        case (GameConstants.AnimDir.Right):
            this.GetComponent <Animator>().SetBool(_walkRight, true);
            //set other flags off
            this.GetComponent <Animator>().SetBool(_walkUp, false);
            this.GetComponent <Animator>().SetBool(_walkLeft, false);
            this.GetComponent <Animator>().SetBool(_walkDown, false);
            break;

        case (GameConstants.AnimDir.Left):
            this.GetComponent <Animator>().SetBool(_walkLeft, true);
            //set other flags off
            this.GetComponent <Animator>().SetBool(_walkUp, false);
            this.GetComponent <Animator>().SetBool(_walkRight, false);
            this.GetComponent <Animator>().SetBool(_walkDown, false);
            break;

        case (GameConstants.AnimDir.Down):
            this.GetComponent <Animator>().SetBool(_walkDown, true);
            //set other flags off
            this.GetComponent <Animator>().SetBool(_walkUp, false);
            this.GetComponent <Animator>().SetBool(_walkRight, false);
            this.GetComponent <Animator>().SetBool(_walkLeft, false);
            break;

        default:
            //empty case
            break;
        }
    }