Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        // 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);
        }
Esempio n. 3
0
        // 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));
        }