// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.F)) { Collider[] colliders = Physics.OverlapSphere(transform.position, pullRadius, layersToPull); foreach (var collider in colliders) { Vector3 direction = transform.position - collider.transform.position; if (direction.magnitude < minRadius) { continue; } float distance = direction.sqrMagnitude * distanceMultiplier + 1; Rigidbody rb = collider.GetComponent <Rigidbody>(); rb.AddForce(direction.normalized * (gravitationalPull / distance) * rb.mass * Time.deltaTime); } } if (Input.GetKeyDown(KeyCode.Mouse0)) { Vector3 v; if (PickThisBlock(out v, 4)) { voxelChunk.DropBlock(v); voxelChunk.SetBlock(v, 0); } } else if (Input.GetKeyDown(KeyCode.Mouse1)) { Vector3 v; if (blockHeld == 1) { if (inventory.itemAmounts[0] > 0) { inventory.itemAmounts[0]--; if (PickEmptyBlock(out v, 4)) { voxelChunk.SetBlock(v, blockHeld); } } } if (blockHeld == 2) { if (inventory.itemAmounts[1] > 0) { inventory.itemAmounts[1]--; if (PickEmptyBlock(out v, 4)) { voxelChunk.SetBlock(v, blockHeld); } } } if (blockHeld == 3) { if (inventory.itemAmounts[2] > 0) { inventory.itemAmounts[2]--; if (PickEmptyBlock(out v, 4)) { voxelChunk.SetBlock(v, blockHeld); } } } if (blockHeld == 4) { if (inventory.itemAmounts[3] > 0) { inventory.itemAmounts[3]--; if (PickEmptyBlock(out v, 4)) { voxelChunk.SetBlock(v, blockHeld); } } } } if (Input.GetKeyDown(KeyCode.Alpha1)) { blockHeld = 1; blocks(blockHeld); } if (Input.GetKeyDown(KeyCode.Alpha2)) { blockHeld = 2; blocks(blockHeld); } if (Input.GetKeyDown(KeyCode.Alpha3)) { blockHeld = 3; blocks(blockHeld); } if (Input.GetKeyDown(KeyCode.Alpha4)) { blockHeld = 4; blocks(blockHeld); } if (Input.GetKeyDown(KeyCode.Tab)) { if (isPaused == false) { isPaused = true; TogglePauseMenu(isPaused); } else { isPaused = false; TogglePauseMenu(isPaused); } } }