// Update is called once per frame void Update() { //Checks if you're holding extra objects, and lets them go if you are if (holding == false && transform.childCount > 0) { transform.GetChild(0).transform.parent = GameObject.Find("world").transform; } //are you indicating that you want to do something with one of the open books? //currently hardcoded into 4 quadrants //selectedBook is a pretty bad name for this if (handL.isLeftHandClosed) { if (handL.getPosX() < 0) { if (handL.getPosY() < 0) { selectBook.selectedBook = 0; } else { selectBook.selectedBook = 2; } } else { if (handL.getPosY() < 0) { selectBook.selectedBook = 1; } else { selectBook.selectedBook = 3; } } } //calculate reach into the z axis float xChunk = (handL.getEasedPosX() - elbowL.getEasedPosX()); float yChunk = (handL.getEasedPosY() - elbowL.getEasedPosY()); measuredArm = xChunk * xChunk + yChunk * yChunk; //you should technically take the square root of this, but mirroring reality exactly is lame reachDepth = ARM_LENGTH * ARM_LENGTH - measuredArm * measuredArm; //and update the position //only kind of a hardcoded nightmare gameObject.transform.localPosition = new Vector3(handL.getEasedPosX() * multiplier, handL.getEasedPosY() * multiplier, (reachDepth * multiplier * 100) - 40); //grab/hold book if (handL.isLeftHandClosed && holding == false || Input.GetKeyDown("o") && holding == false) { if (selectBook.getHeldObject().tag == "closedBook") { selectBook.getHeldObject().transform.SetParent(this.gameObject.transform); holding = true; } } //let go if (Input.GetKeyDown("z") && holding == true) { holding = false; //if its a hand, keep it on your body if (selectBook.getHeldObject().tag == "hand") { selectBook.getHeldObject().transform.parent = GameObject.Find("playerBody").transform; } else { selectBook.getHeldObject().transform.parent = GameObject.Find("world").transform; } } }