//destroys the object that is grabbed when it is added to the Bag public void Bag(Grabdis grabdis) { InventoryResource ir = grabdis.GetComponent <InventoryResource> (); if (ir != null) { this.myInventory.AddResource(ir); Destroy(grabdis.gameObject); } }
//When the object is grabbed, we can ungrab it if it is parented. public void Grab(Grabdis grabdis) { if (grabdis.transform.parent == this.transform) { grabdis.transform.SetParent(null); this.currentGrab = null; //Otherwise, you can grab the item and it will be parented. } else { grabdis.transform.SetParent(this.transform); this.currentGrab = grabdis; } }
//The nearestGrab becomes what is grabbed public void SetNearestGrab(Grabdis grabdis) { this.nearestGrab = grabdis; }