// Start is called before the first frame update void Start() { height = new Vector3(0, gameObject.transform.lossyScale.y / 2, 0); _renderer = gameObject.GetComponent <Renderer>(); _collider = gameObject.GetComponent <Collider>(); _interaction = bookShelf.GetComponent <BookShelfInteraction>(); _lookedAt = bookShelf.GetComponent <BookShelfIsLookedAt>(); _winStateManager = bookShelf.GetComponent <WinStateManager>(); _winStateManager.RegisterPuzzleObject(); _interactableObject = gameObject.GetComponent <InteractableObject>(); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { } Debug.DrawRay(transform.position, -transform.right, Color.green); RaycastHit hit; if (Physics.SphereCast(Camera.main.transform.position, 0.1f, Camera.main.transform.forward, out hit, 100)) { BookShelfInteraction bookShelf = hit.collider.gameObject.GetComponent <BookShelfInteraction>(); if (bookShelf != null && bookShelf != bookShelfInFocus && hasBeenPickedUp) //&& mold != moldInFocus { SetFocus(bookShelf); } else if (bookShelf == null || !hasBeenPickedUp) { RemoveFocus(); } } void SetFocus(BookShelfInteraction newFocus) { //if (newFocus != moldInFocus) //{ if (bookShelfInFocus != null) { bookShelfInFocus.OnDefocus(); } bookShelfInFocus = newFocus; bookShelfInFocus.OnFocus(); //} } void RemoveFocus() { if (bookShelfInFocus != null) { bookShelfInFocus.OnDefocus(); } bookShelfInFocus = null; } }
// Start is called before the first frame update void Start() { _gazeAwareComponent = GetComponent <GazeAware>(); _bookShelfInteraction = GetComponent <BookShelfInteraction>(); randomWaitTime = Random.Range(5f, 10f); }