// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { bool close = Mathf.Abs(pet.GetBed().transform.position.x - pet.transform.position.x) <= tolerence; bool sameFloor = PetUtility.GetFloorNumber(pet.GetBed().transform.position) == PetUtility.GetFloorNumber(pet.transform.position); if (close && sameFloor) { pet.bedNearby = true; } else { pet.bedNearby = false; } }
// 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) { pet = animator.gameObject.GetComponent <Pet>(); //Debug.Log("bed position: " + pet.GetBed().transform.position); bool close = Mathf.Abs(pet.GetBed().transform.position.x - pet.transform.position.x) <= tolerence; bool sameFloor = PetUtility.GetFloorNumber(pet.GetBed().transform.position) == PetUtility.GetFloorNumber(pet.transform.position); if (close && sameFloor) { pet.bedNearby = true; } else { pet.bedNearby = false; } }