Example #1
0
        void OnTriggerStay(Collider other)
        {


            //added by Dan
            //    messageData data = new messageData();


            //data.itemToBeHeld = other.transform.root.gameObject;
            //this.gameObject.SendMessageUpwards("isGrabButtonPressed", data);
            //if (data.isButtonPressed)
            //{
            //    Debug.Log("We're grabbing!!");
            //    if(heldObj != null)
            //    {
            //        if (heldObj.GetComponent<Rigidbody>().isKinematic == false)
            //        {
            //            heldObj.GetComponent<Rigidbody>().isKinematic = true;
            //            heldObj.transform.parent = this.transform;
            //        }
            //        else {
            //            heldObj.GetComponent<Rigidbody>().isKinematic = false;
            //            heldObj.transform.parent = null;
            //            heldObj = null;
            //        }

            //colOn = true;
            //GetComponent<Collider>().enabled = true;




            //other.transform.root.SetParent(this.transform);
            //Rigidbody[] rootRigidbody = (Rigidbody[])data.itemToBeHeld.GetComponents<Rigidbody>();
            //if (rootRigidbody.Length > 0)
            // {
            //     rootRigidbody[0].isKinematic = true;
            //    rootRigidbody[0].useGravity = false;




            //added by Dan

            messageData data = new messageData();
            //other.transform.parent != null && 
            if (other.gameObject.tag == "grab")
            {
                data.itemToBeHeld = other.transform.gameObject;
                this.gameObject.SendMessageUpwards("isGrabButtonPressed", data);
                if (data.isButtonPressed)
                {
                    Debug.Log("We're grabbing!!");
                    other.transform.SetParent(this.transform);
                    Rigidbody[] rootRigidbody = (Rigidbody[])data.itemToBeHeld.GetComponents<Rigidbody>();
                    if (rootRigidbody.Length > 0)
                    {
                        rootRigidbody[0].isKinematic = true;
                        rootRigidbody[0].useGravity = false;

                    }
                }
            }

        }
Example #2
0
    void isGrabButtonPressed(messageData data)
    {
		if(Actions!=null)
		{
	        if (Actions.Grab.IsPressed && pickupTimeoutEnabled == false && itemHeld == null)
	        {
	            data.isButtonPressed = true;
	            itemHeld = data.itemToBeHeld;
	            pickupTimeoutEnabled = true;
	            StartCoroutine(PickupTimer(0.5f));
	        }
		}
    }