override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (movingToCageExit && ghost.HasStopped) { movingToCageExit = false; movingToCagePos = true; ghost.MoveIgnoreCollision(new Vector3[] { MapInfo.CageCenter, ghost.CagePosition }); } else if (movingToCagePos && ghost.HasStopped) { animator.SetBool("is_frightened", false); animator.SetBool("is_retreating", false); animator.SetBool("is_in_cage", true); animator.SetBool("is_leaving_cage", false); } }
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (!ghost.IsReady) { return; } if (ghost.HasStopped && ghost.StartInCage) { if (ghost.CanLeaveCage) { animator.SetBool("is_leaving_cage", true); } else { isMovingDown = !isMovingDown; Vector3 targetOffset = (isMovingDown ? Vector3.down : Vector3.up) * tilemap.cellSize.y / 2f; Vector3 target = ghost.CagePosition + targetOffset; ghost.MoveIgnoreCollision(new Vector3[] { target, ghost.CagePosition }); } } }
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { ghost = !ghost?animator.GetComponent <GhostAI>() : ghost; ghost.MoveIgnoreCollision(new Vector3[] { MapInfo.CageCenter, MapInfo.CageExit }); }