//ObjectPositioning(type); } } if (target && Vector3.Distance(this.transform.position, target.transform.position) >= breakDistance) { PutDown(); } } } public void PickUp (Rigidbody body) { //check if the object is already selected, remove it from list if (heldObject && _selectable != null) { rm.RemoveFromList(target.gameObject, true, false); rm.selectedObjs.Remove(target.gameObject); } target = body; // Set the target heldObject = target.gameObject; //have the object do the pickup changes! _holdable.DoPickup(); //play sounds for pickup! Toolbox.Instance.SetVolume(audioSource); audioSource.clip = pickupClip; audioSource.Play(); } public void PutDown () { //drop the object _holdable.Drop(); _holdable = null; _selectable = null; _rObject = null; heldObject = null; //remove from the list target = null; //plays sound effect Toolbox.Instance.SetVolume(audioSource); audioSource.clip = dropClip; audioSource.Play(); } private void PrepareForPickup() { if (this.gameObject.layer == 15) { newLayerMask.value = LayerMaskController.Laser; } //layermask value of layer 10 is 1024 else if (this.gameObject.layer == 16) { newLayerMask.value = LayerMaskController.Real; } //layermask value of layer 11 is 2048 Ray r = new Ray(mainCamera.transform.position, mainCamera.transform.forward); RaycastHit hit; if (Physics.Raycast(r, out hit, MaxPickupDistance, newLayerMask.value)) // Otherwise, if target was null, shoot a ray where we are aiming. { Rigidbody body = hit.collider.attachedRigidbody; _rObject = body.GetComponent<ReticleObject>(); _holdable = _rObject as IHoldable; _selectable = _rObject as ISelectable; Transition transition = body.GetComponent<Transition>(); //for picking up actual objects if (_holdable != null && body && ((body.gameObject.layer + 5) == this.gameObject.layer) && !CheckPlayerStance(body.gameObject) && transition && !transition.GetTransitioning()) { PickUp(body); } } } public void KillPickup() { target = null; heldObject = null; _holdable = null; _selectable = null; _rObject = null; } private bool CheckPlayerStance(GameObject obj) {