public void dropBag(Vector3 bagDropPosition) { if (bagDropPosition != Vector3.zero) { currentBagPlacing.transform.position = new Vector3(bagDropPosition.x, bagDropPosition.y + currentBagPlacing.halfBagHeight, bagDropPosition.z); } currentBagPlacing.disableInitialColliders(); currentBagPlacing.freezeContents(); currentBagPlacing.setGravity(true); }
IEnumerator placeItemsInBagAndDrop(BagProperties bagProperties, List <BagContentProperties> items, String randomSeed) { Vector3 bagSize = bagProperties.placingCube.transform.localScale; foreach (BagContentProperties item in items) { item.transform.parent = bagProperties.contents.transform; Vector3 objectSize = item.objectSize; item.transform.localPosition = new Vector3(ItsRandom.randomPlusMinus(0f, (bagSize.x - objectSize.x) / 2f, randomSeed), bagProperties.halfBagHeight, ItsRandom.randomPlusMinus(0f, (bagSize.z - objectSize.z) / 2f, randomSeed)); item.transform.localScale = Vector3.one; bagProperties.bagContents.Add(item); bagProperties.freezeContents(true); yield return(new WaitForSeconds(0.1f)); } yield return(new WaitForSeconds(0.6f)); dropBag(Vector3.zero); }