public bool EatObject(GameObject g) //returns true once the object has been eaten { Vector3 foodGroundPos = g.transform.position; foodGroundPos.y = GroundLevel; if (Vector3.Distance(mHead.transform.position, g.transform.position) < 0.35f) //eats from hand { state.SetState(MonsterState.States.EatHand); state.SetAnimationState(MonsterState.animStates.EatHand); mStats.EatFood(g.GetComponent <Valve.VR.InteractionSystem.Edible>().type.ToString()); g.SetActive(false); state.SetEmotion(MonsterState.Emotions.Happy); timer += Time.deltaTime; if (timer > 2) { return(true); } } else if (Vector3.Distance(mHead.transform.position, g.transform.position) < 0.8f) //eats from ground { state.foodObj = g; state.SetState(MonsterState.States.EatGround); state.SetAnimationState(MonsterState.animStates.EatGround); Quaternion foodRotation = Quaternion.LookRotation(transform.position - g.transform.position); Quaternion foodGroundRotation = Quaternion.LookRotation(transform.position - foodGroundPos); transform.rotation = Quaternion.Slerp(transform.rotation, foodGroundRotation, 3 * Time.deltaTime); mHead.transform.rotation = Quaternion.Slerp(mHead.transform.rotation, foodRotation, 5 * Time.deltaTime); timer += Time.deltaTime; if (timer > 2) { mStats.EatFood(g.GetComponent <Valve.VR.InteractionSystem.Edible>().type.ToString()); g.SetActive(false); state.SetEmotion(MonsterState.Emotions.Happy); return(true); } } else { timer = 0; Quaternion foodRotation = Quaternion.LookRotation(transform.position - g.transform.position); Quaternion foodGroundRotation = Quaternion.LookRotation(transform.position - foodGroundPos); transform.rotation = Quaternion.Slerp(transform.rotation, foodGroundRotation, 3 * Time.deltaTime); mHead.transform.rotation = Quaternion.Slerp(mHead.transform.rotation, foodRotation, 5 * Time.deltaTime); transform.position = Vector3.MoveTowards(transform.position, foodGroundPos, totalSpeed * Time.deltaTime); state.SetAnimationState(MonsterState.animStates.Walking); } return(false); }