private void CheckIfItemHasCollided() { Ray ray = new Ray(this.transform.position, this.transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, 80) && Time.time > nextRayCheckTime) { ItemRaycastableController item = hit.transform.gameObject.GetComponent <ItemRaycastableController>(); if (item != null) { Debug.Log(item.name); } } }
void Update() { Ray ray = new Ray(this.transform.position, this.transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, 2)) { if (WorldManager.isTooltipActive == false) { ItemRaycastableController item = hit.transform.gameObject.GetComponent <ItemRaycastableController>(); if (item != null && item.showInteractTooltip) { WorldManager.setTooltip(item.tooltipText); } } } else { WorldManager.removeTooltip(); } }