예제 #1
0
    // 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;
        }
    }
예제 #2
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)
    {
        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;
        }
    }