void UpdateRaycast() { hoverCollider = null; crosshair.SetActive(false); RaycastHit hit; Physics.Raycast(raycastFrom.position, raycastFrom.forward, out hit, raycastDistance); if (!hit.collider) { return; } hoverCollider = hit.collider; // interactable Interactable interactable = hit.collider.GetComponent <Interactable>(); if (interactable) { if (NInput.GetMouseButtonDown(1)) { if (isServer) { interactable.Act(); } else { CmdInteract(interactable.gameObject); } } } if (interactable is Item) { if (NInput.GetMouseButtonDown(1)) { Item item = interactable as Item; Take(item); } } if (interactable) { crosshair.SetActive(true); } }
void Update() { if (!isLocalPlayer) { return; } UpdateHand(); UpdateRaycast(); UpdateDescription(); if (NInput.GetMouseButtonDown(0)) { UseOnce(); } if (NInput.GetMouseButton(0)) { Use(); } if (NInput.GetMouseButtonUp(0)) { triggerDown = false; } if (NInput.GetMouseButtonDown(1)) { StartAim(); } if (NInput.GetMouseButtonUp(1)) { EndAim(); } if (NInput.GetKeyDown(KeyCode.Q)) { Drop(); } mouseSpeed = new Vector3(NInput.GetAxis("Mouse X"), NInput.GetAxis("Mouse Y"), 0); }