// Update is called once per frame void Update() { if (Input.GetButtonDown("Inventory")) { if (inventory.UIItemInHands.transform.parent.gameObject.activeSelf && inventory.UIInventory.transform.parent.gameObject.activeSelf) { inventory.hideInventory(); Cursor.lockState = CursorLockMode.Locked; usingInventory = false; } else { inventory.showInventory(); Cursor.lockState = CursorLockMode.None; usingInventory = true; } } if (!usingInventory) { movementHandle(); rotationHandle(); stanceHandle(); //Shooting if (Input.GetButtonDown("Fire1")) { if (inventory.getItemInHands() is UsableItem) { UsableItem a = inventory.getItemInHands() as UsableItem; a.use(); } } //Reloading if (Input.GetButtonDown("Reload")) { if (inventory.getItemInHands() is Rifle) { Rifle rifle = inventory.getItemInHands() as Rifle; rifle.reload(); } } if (Input.GetButtonDown("Aim")) { if (inventory.getItemInHands() is Rifle) { Rifle rifle = inventory.getItemInHands() as Rifle; rifle.aim(); } } if (Input.GetButtonUp("Aim")) { if (inventory.getItemInHands() is Rifle) { Rifle rifle = inventory.getItemInHands() as Rifle; rifle.aim(); } } if (Input.GetButtonDown("Interact")) { RaycastHit raycastHit; Ray ray = new Ray(playerCamera.transform.position, playerCamera.transform.forward); if (Physics.Raycast(ray, out raycastHit, 2)) { //Debug.DrawLine(playerCamera.transform.position, raycastHit.point, Color.red, 10); if (raycastHit.collider.gameObject.CompareTag("Pickupable")) { if (inventory.addItem(raycastHit.collider.transform.Find("Pickupable").GetComponent <pickupScript>().item)) { Destroy(raycastHit.collider.gameObject); } } } } } }