public void GrabArrow(Arrow arrow) { arrowGrabber = ClosestGrabber; // Signal the grabbable that we're being held GrabbedArrow = arrow.GetComponent <Arrow>(); GrabbedArrow.ShaftCollider.enabled = false; arrowGrabbable = arrow.GetComponent <Grabbable>(); if (arrowGrabbable) { arrowGrabbable.GrabItem(arrowGrabber); arrowGrabber.HeldGrabbable = arrowGrabbable; arrowGrabbable.AddControllerVelocityOnDrop = false; } Collider playerCollder = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <Collider>(); if (playerCollder) { Physics.IgnoreCollision(GrabbedArrow.ShaftCollider, playerCollder); } holdingArrow = true; }
// Assign new held Item, then grab the item into our hand / controller public void GrabGrabbable(Grabbable item) { // We are trying to grab something else if (flyingGrabbable != null && item != flyingGrabbable) { return; } // Make sure we aren't flying an object at us still resetFlyingGrabbable(); // Drop whatever we were holding if (HeldGrabbable != null && HeldGrabbable) { TryRelease(); } // Assign new grabbable HeldGrabbable = item; // Just grabbed something, no longer fresh. FreshGrip = false; // Let item know it's been grabbed item.GrabItem(this); }
// Assign new held Item, then grab the item into our hand / controller public void GrabGrabbable(Grabbable item) { // We are trying to grab something else if (flyingGrabbable != null && item != flyingGrabbable) { return; } // Make sure we aren't flying an object at us still resetFlyingGrabbable(); // Drop whatever we were holding if (HeldGrabbable != null && HeldGrabbable) { Debug.Log("Try release:" + HeldGrabbable.name); TryRelease(); } // Assign new grabbable HeldGrabbable = item; // Just grabbed something, no longer fresh. FreshGrip = false; Debug.Log("Grabbb in grabber: " + item.name); // Let item know it's been grabbed item.GrabItem(this); Grab?.Invoke(new GrabbableEventArgs(item, this)); }