GetCurrentAnimatorStateInfo() публичный Метод

public GetCurrentAnimatorStateInfo ( int layerIndex ) : AnimatorStateInfo
layerIndex int
Результат AnimatorStateInfo
Пример #1
0
        public override void OnUpdate()
        {
            FixChangeAnimationBug();

            if (StartUpdate == false || eventIndex.Value == -1)
            {
                return;
            }


            if (NormalizedTime != null && NormalizedTime.Length == events.Length)
            {
                if (NormalizedTime[eventIndex.Value].Value != 0)
                {
                    for (int i = 0; i < Fsm.ActiveState.Actions.Length; i++)
                    {
                        if (Fsm.ActiveState.Actions[i] as AnimatorCrossFade != null)
                        {
                            AnimatorCrossFade data = Fsm.ActiveState.Actions[i] as AnimatorCrossFade;
                            if (_animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= NormalizedTime[eventIndex.Value].Value &&
                                _animator.GetCurrentAnimatorStateInfo(0).IsName(data.stateName.Value))
                            {
                                Fsm.Event(events[eventIndex.Value]);
                                Finish();
                            }
                            return;
                        }
                    }
                }
            }
        }
Пример #2
0
    private IEnumerator WaitForAnimation(Animator animator)
    {
        do
        {
            yield return null;
        } while (animator.GetCurrentAnimatorStateInfo(0).IsName("Armature|Victory") || animator.GetCurrentAnimatorStateInfo(0).IsName("Armature|Victory0") || animator.IsInTransition(0));

        laser.SetActive(true);
    }
Пример #3
0
    /// <summary>
    /// cache animator states and their data
    /// </summary>
    public static void CacheAnimState(Animator anim, out int[] animStateNames, out float[] animStateTimes)
    {
        animStateNames = new int[anim.layerCount];
        animStateTimes = new float[anim.layerCount];

        for (int i = 0; i < anim.layerCount; i++)
        {
            animStateNames[i] = anim.GetCurrentAnimatorStateInfo(i).fullPathHash;
            animStateTimes[i] = anim.GetCurrentAnimatorStateInfo(i).normalizedTime;
        }
    }
Пример #4
0
    bool CheckDamage()
    {
        if (animator.GetCurrentAnimatorStateInfo(0).IsName("LeftHit") || animator.GetCurrentAnimatorStateInfo(0).IsName("RightHit"))
        {
            return(true);
        }

        return(false);
    }
 /// <summary>
 // Checks if the animator is in a specified state on any of its layers, and
 // returns the state info.
 /// </summary>
 /// <returns><c>true</c>, if in the state, <c>false</c> otherwise.</returns>
 /// <param name="animator">Animator.</param>
 /// <param name="stateName">State name.</param>
 /// <param name="animatorStateInfo">(Out) Animator state info.</param>
 private bool CheckIsInState(Animator animator, string stateName, out AnimatorStateInfo animatorStateInfo)
 {
     if (animator != null) {
         for (int layerIndex = 0; layerIndex < animator.layerCount; layerIndex++) {
             AnimatorStateInfo info = animator.GetCurrentAnimatorStateInfo(layerIndex);
             if (info.IsName(stateName)) {
                 animatorStateInfo = info;
                 return true;
             }
         }
     }
     animatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
     return false;
 }
Пример #6
0
 //private float _seed = 0.0f;
 // Use this for initialization
 void Start()
 {
     anim = GetComponent<Animator> ();
     currentState = anim.GetCurrentAnimatorStateInfo (0);
     previousState = currentState;
     StartCoroutine ("RandomChange");
 }
Пример #7
0
    public void WallJump(Animator myAnimator, Rigidbody2D myRigidbody2D, WallCheck[] allWallChecks)
    {
        if(!lockWallJump)
        {
            foreach(WallCheck localWallCheck in allWallChecks)
            {
                if(localWallCheck.walled)
                {
                    lockWallJump = true;
                    if(myRigidbody2D.transform.localScale.x < 0)
                    {
                        myRigidbody2D.AddForce(new Vector2(myRigidbody2D.velocity.x + jumpForce.x, jumpForce.y));
                    }
                    else
                    {
                        myRigidbody2D.AddForce(new Vector2(myRigidbody2D.velocity.x - jumpForce.x, jumpForce.y));
                    }

                    if(!myAnimator.GetCurrentAnimatorStateInfo(0).IsName(jumpAnimationName))
                    {
                        myAnimator.SetTrigger(jumpAnimationTriggerName);
                    }
                    Invoke ("UnlockWallJump", lockTime);
                    break;
                }
            }
        }
    }
Пример #8
0
 // Use this for initialization
 void Start()
 {
     material = GetComponentInChildren<Renderer>().materials[qualMaterial];
     animator = GetComponent<Animator>();
     if(animator)
         animaState = animator.GetCurrentAnimatorStateInfo(0);
 }
Пример #9
0
    // Update is called once per frame
    void Update()
    {
        tempo+=Time.deltaTime;

        if(animator)
        {
            animaState = animator.GetCurrentAnimatorStateInfo(0);
            if(animaState.IsName("padrao")){
                if(tempo>TEMPO_DE_PISCAR )
                {
                    piscarAgora();
                }
            }else if(animaState.IsName("cair")){
                material.mainTextureOffset = new Vector3(3*deslocamento,0);
            }else if(animaState.IsName("dano1")){
                tempo = TEMPO_DE_PISCAR;
                piscarAgora();
            }else
                material.mainTextureOffset = new Vector3(0,0);
        }else
        {
            animator = GetComponent<Animator>();
            if(animator)
                animaState = animator.GetCurrentAnimatorStateInfo(0);
        }
    }
Пример #10
0
 // Use this for initialization
 void Start()
 {
     // 各参照の初期化
     anim = GetComponent<Animator> ();
     currentState = anim.GetCurrentAnimatorStateInfo (0);
     previousState = currentState;
 }
Пример #11
0
	public AnimatorHelper (Animator a)
	{
		animator = a;
		currentState_ = animator.GetCurrentAnimatorStateInfo (0);

		RefreshSubAnimators ();
	}
Пример #12
0
 /// <summary>
 /// Returns true when the current state is active.
 /// </summary>
 /// <param name="name">name of state</param>
 /// <param name="animator">animator object</param>
 /// <returns></returns>
 public static bool IsStateActive(string name, Animator animator)
 {
     for (int i = 0; i < animator.layerCount; i++)
     {
         if (animator.GetCurrentAnimatorStateInfo(i).IsName(name)) return true;
     }
     return false;
 }
 public static bool IsName(Animator anim,string name)
 {
     if (anim)
     {
         return anim.GetCurrentAnimatorStateInfo(Default_Layer).IsName(name);
     }
     return false;
 }
 public static bool IsDone(Animator anim, int loopCount = 1)
 {
     if (anim)
     {
         return anim.GetCurrentAnimatorStateInfo(Default_Layer).normalizedTime >= (float)loopCount;
     }
     return true;
 }
Пример #15
0
 private void Awake()
 {
     action = playerAction.normal;
     anim = GetComponent<Animator>();
     attackColl = GameObject.Find(PathHelper.playerAttackColliderPath).GetComponent<SphereCollider>();
     stateInfo = anim.GetCurrentAnimatorStateInfo(0);
     characterController = GetComponent<CharacterController>();
 }
Пример #16
0
		// Use this for initialization
		void Start ()
		{
			// 各参照の初期化
			anim = GetComponent<Animator> ();
			currentState = anim.GetCurrentAnimatorStateInfo (0);
			previousState = currentState;
			// ランダム判定用関数をスタートする
			StartCoroutine ("RandomChange");
		}
Пример #17
0
 void Start()
 {
     anim = GetComponent<Animator>();
     clipHash = Animator.StringToHash(clipName);
     anim.Play(clipHash, 0, startFrame);
     clipLength = anim.GetCurrentAnimatorStateInfo(0).length;
     t = startFrame * clipLength;
     anim.speed = 0;
 }
    void Awake()
    {
        playerAnim = this.GetComponent<Animator>();
        currentBaseState = playerAnim.GetCurrentAnimatorStateInfo(0);

        //Movement
        GetComponent<Rigidbody>().freezeRotation = true;
        GetComponent<Rigidbody>().useGravity = false;
    }
Пример #19
0
	override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 
	{
		if(animator.GetCurrentAnimatorStateInfo(0).fullPathHash == AnimationIDs.IDLE_STATE)
		{
			PlayerMovement playerMovement = animator.gameObject.GetComponent<PlayerMovement>();
			playerMovement.MoveLocked = false;
			playerMovement.ForceAim = false;
		}
	}
Пример #20
0
    // Update is called once per frame
    void Update()
    {
        if (hasFinish)
        {
            return;
        }

        AnimatorStateInfo animatorInfo;

        animatorInfo = fire_.GetCurrentAnimatorStateInfo(0);                       //要在update获取
        if ((animatorInfo.normalizedTime > 1.0f) && (animatorInfo.IsName("fire"))) //normalizedTime:0-1在播放、0开始、1结束 MyPlay为状态机动画的名字
        {
            foreach (Transform tr in transform)
            {
                if (tr.gameObject.name == "Fire")
                {
                    Destroy(tr.gameObject);
                    DropFruits();
                    hasFinish = true;
                }
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            flag = false;
        }
        if (!flag && Input.GetMouseButtonDown(0))
        {
            t_MouseDown = DateTime.Now;
            flag        = true;
        }


        if (flag)
        {
            var          ray            = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit[] hits           = Physics.RaycastAll(ray);
            bool         isHitSprite    = false;
            bool         isHitIceRivets = false;
            foreach (RaycastHit hit in hits)
            {
                if (hit.collider.gameObject.tag == gameObject.tag)
                {
                    isHitIceRivets = true;
                    GameObject boy = GameObject.Find("BoySprite");
                    time_ = Mathf.Abs(Vector3.Distance(boy.transform.position, hit.transform.position)) / 8;
                    break;
                }
            }
            if (isHitIceRivets && !uiManager.isBtnShowing)
            {
                Invoke("StartFire", time_);
            }
        }
    }
Пример #21
0
    // 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) {
    //
    //}

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (ApplicationModel.Instance.State != GameState.StartGame && ApplicationModel.Instance.State != GameState.InGame)
        {
            AnimatorStateInfo currentState = animator.GetCurrentAnimatorStateInfo(0);
            float playbackTime = currentState.normalizedTime % 1;
            if (playbackTime > 0.8f && playbackTime < 0.9f)
                ApplicationModel.Instance.State = GameState.CharacterSelection;
        }
    }
Пример #22
0
	void UpdateStatePower(Animator animator, AnimatorStateInfo stateInfo, int layerIndex){
		AnimatorTransitionInfo info = animator.GetAnimatorTransitionInfo (layerIndex);

		if (animator.GetNextAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()) { //Entering the state
			_power = info.normalizedTime;
		}else if(animator.GetCurrentAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()){ //Exiting the state
			_power = (1-info.normalizedTime);
		}

	}
    // Updates the progress counter of this animation state.
    void UpdateStateProgress (Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
        AnimatorTransitionInfo info = animator.GetAnimatorTransitionInfo (layerIndex);

        if (animator.GetNextAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()) { //Entering the state
            m_progress = info.normalizedTime; // Set progress of the animation to the time taken so far.
        } else if(animator.GetCurrentAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()){ //Exiting the state
            m_progress = (1 - info.normalizedTime); // Set the final progress of the animation.
        }

    }
Пример #24
0
    // Use this for initialization
    void Awake()
    {
        //getting animator component
        anim = GetComponent<Animator>();

        //assign the ground game object
        ground = transform.FindChild("ground");

        //getting the animation state base
        currentBaseState = anim.GetCurrentAnimatorStateInfo(0);
    }
Пример #25
0
 void Start()
 {
     Initialize (this.GetType().FullName);
     CombineInitParts();
     likeMeal = "Meat";
     dislikeMeal = "Fish";
     likeCare = "Bone";
     dislikeCare = "Ring";
     animator = GetComponent (typeof(Animator)) as Animator;
     AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0);
 }
Пример #26
0
	// Use this for initialization
	void Start ()
	{
		// 各参照の初期化
//		last = Time.time;
		anim = GetComponent<Animator> ();
		currentState = anim.GetCurrentAnimatorStateInfo (0);
		previousState = currentState;
		anim.SetBool ("Next",true);
		// ランダム判定用関数をスタートする
//		StartCoroutine ("RandomChange");
	}
Пример #27
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            AnimatorStateInfo info = _animator.GetCurrentAnimatorStateInfo(0);

            if (info.normalizedTime >= NormalizedTime.Value &&
                info.IsName(rootAnimationStateName))
            {
                Fsm.SetState(ReturnStateName.Value);
                Finish();
            }
        }
	IEnumerator DoPanelClose(Animator anim)
	{
		//Debug.Log ("Closing " + anim.gameObject.name);
		anim.SetBool(paramName, false);
		bool stateReached = false;
		while(!stateReached) {
			stateReached = anim.GetCurrentAnimatorStateInfo(0).IsName("Closed");
			yield return new WaitForEndOfFrame();
		}
		//Debug.Log ("Closing animation finished");
		anim.gameObject.SetActive(false);
	}
Пример #29
0
    public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        base.OnStateUpdate(animator, stateInfo, layerIndex);
        Debug.Log(animator.runtimeAnimatorController.animationClips[0].wrapMode);
        //Debug.Log(animator.GetCurrentAnimatorClipInfo(layerIndex)[0].clip.isLooping);

        if (animator.runtimeAnimatorController.animationClips[0].wrapMode == WrapMode.Once) {
            if (animator.GetCurrentAnimatorStateInfo(layerIndex).normalizedTime >= 1f) {
                animator.SetBool("isExit", true);
            }
        }
    }
Пример #30
0
	 // 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) {
	//
	//}

	// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
	override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
		AnimatorTransitionInfo info = animator.GetAnimatorTransitionInfo (layerIndex);
		if (animator.GetNextAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()) { //Entering the state
			_power = info.normalizedTime;
		}else if(animator.GetCurrentAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()){ //Exiting the state
			_power = (1-info.normalizedTime);
		}
		if (_power > 0.98f) {
			animator.SetBool ("Holstered", true);
			animator.SetBool ("Holster", false);
		}
	}
    void Start()
    {
        animator = GetComponent<Animator> ();

        animator.GetCurrentAnimatorStateInfo (0);

        if (animator.layerCount >= 2) {
            animator.SetLayerWeight (1, 1);
        }

        m_LocomotionId = Animator.StringToHash ("Base Layer.Locomotion");
    }
Пример #32
0
    void Update()
    {
        time += Time.deltaTime * 1;
//		print ("时间:"+time)
        if (time > Max_time)
        {
            Destroy(this.gameObject);
        }
        if (animator && animator.GetCurrentAnimatorStateInfo(0).normalizedTime > 1)
        {
            Destroy(this.gameObject);
        }
    }
Пример #33
0
    //private int _animState = Animator.StringToHash("scratchAnimation");
    void Awake()
    {
        attackTrigger.enabled = false;
        rb = Player.GetComponent<Rigidbody2D>();
        //		_animator = GetComponent<Animator>();
        _attackAnimator = attackAnim.GetComponent<Animator>();

        // get the length of the Scratch Animation and set the cooldown
        AnimatorStateInfo state = _attackAnimator.GetCurrentAnimatorStateInfo( 0 );
        float scratchLength = state.length;
        // Debug.Log(scratchLength);
        attackCoolDown = scratchLength;
    }
Пример #34
0
 public void Jump(Animator myAnimator, Rigidbody2D myRigidbody2D, GroundCheck groundCheck)
 {
     if(groundCheck.grounded && !lockJump)
     {
         lockJump = true;
         if(!myAnimator.GetCurrentAnimatorStateInfo(0).IsName(jumpAnimationName))
         {
             myAnimator.SetTrigger(jumpAnimationTriggerName);
             myRigidbody2D.AddForce(jumpForce);
         }
         Invoke("UnlockJump", lockTime);
     }
 }
	// 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) {
	    
    }*/

	// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
	override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
        fieldView = animator.GetComponent<Soldier_FieldOfView>();
        
        //Shooting Animation
        if(animator.GetCurrentAnimatorStateInfo(0).IsName("soldierReadyToFire")){
           fieldView.ShootTarget();                                                                  
        }

        //Sprinting Animation
        if(animator.GetCurrentAnimatorStateInfo(0).IsName("soldierSprint")){
           fieldView.SearchTarget();                                                                
        }
        
        //Idle Animation
        else if(animator.GetCurrentAnimatorStateInfo(0).IsName("soldierIdle")){
           fieldView.StandBy();
        }
        
        //Dead Animation
        else if(animator.GetCurrentAnimatorStateInfo(0).IsName("soldierDieFront") || animator.GetCurrentAnimatorStateInfo(0).IsName("soldierDieBack")){
           fieldView.SuspendAllBehaviors();
        } 
    }
    // Update is called once per frame
    void Update()
    {
        AnimatorStateInfo animatorInfo;

        animatorInfo = melt_.GetCurrentAnimatorStateInfo(0);                         //要在update获取
        if ((animatorInfo.normalizedTime > 1.0f) && (animatorInfo.IsName("4-melt"))) //normalizedTime:0-1在播放、0开始、1结束 MyPlay为状态机动画的名字
        {
            Destroy(gameObject);
        }
        if ((animatorInfo.normalizedTime > 1.0f) && (animatorInfo.IsName("4-onlymelt")))//normalizedTime:0-1在播放、0开始、1结束 MyPlay为状态机动画的名字
        {
            fire_.SetBool("isFire", false);
        }
        if (Input.GetMouseButtonUp(0))
        {
            flag = false;
        }
        if (!flag && Input.GetMouseButtonDown(0))
        {
            t_MouseDown = DateTime.Now;
            flag        = true;
        }

        if (flag)
        {
            var          ray          = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit[] hits         = Physics.RaycastAll(ray);
            bool         isHitIceCube = false;
            foreach (RaycastHit hit in hits)
            {
                //print(hit.collider.name);
                if (hit.collider.gameObject.tag == tag)
                {
                    isHitIceCube = true;
                    GameObject boy = GameObject.Find("BoySprite");
                    time_ = Mathf.Abs(Vector3.Distance(boy.transform.position, hit.transform.position)) / 8;
                    break;
                }
            }
            if (isHitIceCube && !uiManager.isBtnShowing)
            {
                Invoke("StartFire", time_);
            }
        }
    }
Пример #37
0
        public sealed override void OnStateUpdate(UnityEngine.Animator animator, AnimatorStateInfo stateInfo, int layerIndex, AnimatorControllerPlayable controller)
        {
            if (!animator.gameObject.activeSelf)
            {
                return;
            }

            if (animator.IsInTransition(layerIndex) && animator.GetNextAnimatorStateInfo(layerIndex).fullPathHash == stateInfo.fullPathHash)
            {
                OnSLTransitionToStateUpdate(animator, stateInfo, layerIndex);
                OnSLTransitionToStateUpdate(animator, stateInfo, layerIndex, controller);
            }

            if (!animator.IsInTransition(layerIndex) && m_FirstFrameHappened)
            {
                OnSLStateNoTransitionUpdate(animator, stateInfo, layerIndex);
                OnSLStateNoTransitionUpdate(animator, stateInfo, layerIndex, controller);
            }

            if (animator.IsInTransition(layerIndex) && !m_LastFrameHappened && m_FirstFrameHappened)
            {
                m_LastFrameHappened = true;

                OnSLStatePreExit(animator, stateInfo, layerIndex);
                OnSLStatePreExit(animator, stateInfo, layerIndex, controller);
            }

            if (!animator.IsInTransition(layerIndex) && !m_FirstFrameHappened)
            {
                m_FirstFrameHappened = true;

                OnSLStatePostEnter(animator, stateInfo, layerIndex);
                OnSLStatePostEnter(animator, stateInfo, layerIndex, controller);
            }

            if (animator.IsInTransition(layerIndex) && animator.GetCurrentAnimatorStateInfo(layerIndex).fullPathHash == stateInfo.fullPathHash)
            {
                OnSLTransitionFromStateUpdate(animator, stateInfo, layerIndex);
                OnSLTransitionFromStateUpdate(animator, stateInfo, layerIndex, controller);
            }
        }
Пример #38
0
    // Update is called once per frame
    void Update()
    {
        AnimatorStateInfo animatorInfo;

        if (melt_ != null)
        {
            animatorInfo = melt_.GetCurrentAnimatorStateInfo(0);
            if ((animatorInfo.normalizedTime < 1.0f) && (animatorInfo.normalizedTime > 0.0f) && (animatorInfo.IsName("4-melt")))//normalizedTime:0-1在播放、0开始、1结束 MyPlay为状态机动画的名字
            {
                if (isLeft)
                {
                    if (rope == null)
                    {
                        waterRise.SetBool("IsRaise", true);
                    }
                }
                else
                {
                    waterRise.SetBool("IsRaise", true);
                }
            }
        }
    }
Пример #39
0
    // Update is called once per frame
    void Update()
    {
        transform.LookAt(marioCamera);

        X         = (Input.GetAxisRaw("Horizontal") * Time.deltaTime) * speed;
        Y         = (Input.GetAxisRaw("Vertical") * Time.deltaTime) * speed;
        yVelocity = rb.velocity.y;

        if (X != 0 || Y != 0)
        {
            IsMoving = 1;
        }
        else if (X == 0 && Y == 0)
        {
            IsMoving = 0;
        }

        if (Physics.Raycast(transform.position, -Vector3.up, out hit) && isGrounded == true)
        {
            constDistanceToGround = hit.distance;
        }

        if (Physics.Raycast(transform.position, -Vector3.up, out hit))
        {
            distanceToGround = hit.distance;
        }

        if (Input.GetKeyDown(KeyCode.Z) && isGrounded)
        {
            isGrounded = false;
            rb.AddForce(jump * jumpForce, ForceMode.Impulse);
        }

        //Animation crap :)
        //Walk anim
        if (isGrounded == true)
        {
            if (X > 0 && Y == 0)
            {
                spriteRenderer.flipX = true;
                direction            = 1;
                animator.Play("Walkpm");
            }
            else if (X == 0 && Y < 0)
            {
                if (direction == 8)
                {
                    spriteRenderer.flipX = false;
                    animator.Play("downleftpm");
                }
                else if (direction == 5)
                {
                    spriteRenderer.flipX = true;
                    animator.Play("downleftpm");
                }
                else if ((direction == 4) || (direction == 1))
                {
                    spriteRenderer.flipX = true;
                    direction            = 5;
                    animator.Play("downleftpm");
                }
                else
                {
                    spriteRenderer.flipX = false;
                    animator.Play("downleftpm");
                    direction = 8;
                }
            }
            else if (X == 0 && Y > 0)
            {
                if (direction == 4)
                {
                    spriteRenderer.flipX = true;
                    animator.Play("walkuppm");
                }
                else if ((direction == 7) || (direction == 6))
                {
                    spriteRenderer.flipX = false;
                    animator.Play("walkuppm");
                    direction = 7;
                }
                else if ((direction == 5) || (direction == 1))
                {
                    spriteRenderer.flipX = true;
                    direction            = 4;
                    animator.Play("walkuppm");
                }
                else
                {
                    spriteRenderer.flipX = false;
                    animator.Play("walkuppm");
                    direction = 7;
                }
            }
            else if (X > 0 && Y > 0)
            {
                spriteRenderer.flipX = true;
                direction            = 4;
                animator.Play("walkuppm");
            }
            else if (X > 0 && Y < 0)
            {
                spriteRenderer.flipX = true;
                direction            = 5;
                animator.Play("downleftpm");
            }
            else if (X < 0 && Y == 0)
            {
                spriteRenderer.flipX = false;
                direction            = 6;
                animator.Play("Walkpm");
            }
            else if (X < 0 && Y > 0)
            {
                spriteRenderer.flipX = false;
                direction            = 7;
                animator.Play("walkuppm");
            }
            else if (X < 0 && Y < 0)
            {
                spriteRenderer.flipX = false;
                direction            = 8;
                animator.Play("downleftpm");
            }
            else if ((X == 0 && Y == 0) && direction == 1)
            {
                spriteRenderer.flipX = true;
                animator.Play("downleftidlepm");
            }
            else if ((X == 0 && Y == 0) && direction == 4)
            {
                spriteRenderer.flipX = true;
                animator.Play("upidlepm");
            }
            else if ((X == 0 && Y == 0) && direction == 5)
            {
                spriteRenderer.flipX = true;
                animator.Play("downleftidlepm");
            }
            else if ((X == 0 && Y == 0) && direction == 6)
            {
                spriteRenderer.flipX = false;
                animator.Play("downleftidlepm");
            }
            else if ((X == 0 && Y == 0) && direction == 7)
            {
                spriteRenderer.flipX = false;
                animator.Play("upidlepm");
            }
            else if ((X == 0 && Y == 0) && direction == 8)
            {
                spriteRenderer.flipX = false;
                animator.Play("downleftidlepm");
            }
        }

        //jump anim
        if ((animator.GetCurrentAnimatorStateInfo(0).IsName("right") || animator.GetCurrentAnimatorStateInfo(0).IsName("Walk")) && isGrounded == false && ((yVelocity > 0) || (yVelocity < 0)) && (spriteRenderer.flipX == false))
        {
            animator.Play("jumpright");
        }
        else if ((animator.GetCurrentAnimatorStateInfo(0).IsName("jumpright") || animator.GetCurrentAnimatorStateInfo(0).IsName("Walk")) && isGrounded == false && (yVelocity > -0.1 && yVelocity < 0.1))
        {
            animator.Play("jumpright2");
        }
    }