void Update() { RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit, 3f) && allowInput) //raycast to detect item { current = hit.collider; ui = hit.collider.GetComponent <IInterface>(); if (ui != null) { if (!newColider) { ui.ChangeInterface(hit.point); //keeping the ui change from updating every frame prev = hit.collider; newColider = true; } if (prev != current) { newColider = false; } } else { SetUI(3, ""); newColider = false; } if (!isMoving) { if (Input.GetMouseButtonDown(0)) { lookAt = hit.collider.GetComponent <IInteract>(); if (lookAt != null) { lookAt.OnClick(hit, guide); //calling the OnClick function for that object } } else if (Input.GetKeyDown(KeyCode.E)) { IOtherInput other = hit.collider.GetComponent <IOtherInput>(); if (other != null) { other.OnKeyInput(); //only flips food at the moment } } else if (Input.GetMouseButtonDown(2)) //middle mouse button { IOtherInput other = hit.collider.GetComponent <IOtherInput>(); if (other != null) { other.OnMouseInput(); //dismantles food stack } } } else { SetUI(3, ""); newColider = false; } } else { SetUI(3, ""); newColider = false; } if (Input.GetMouseButtonDown(1) && allowInput)// { if (GetHolding() != null && !isMoving) { OnDrop(hit); } } if (!allowInput) { itemText.enabled = false; retical.enabled = false; } else { itemText.enabled = true; retical.enabled = true; } }