public void MakeItem() { GameObject item = GoodsCupObjectPool.GetObject(); item.transform.position = Vector3.zero; float ranScale = Random.Range(0.1f, 0.7f); item.transform.localScale = new Vector3(ranScale, ranScale, 0.3f); Rigidbody2D itemRigid = item.GetComponent <Rigidbody2D>(); Vector2 popVect = new Vector2(Random.Range(-1f, 1f), Random.Range(2f, 3f)); itemRigid.AddForce(popVect, ForceMode2D.Impulse); StartCoroutine("DestroyGoods", item); }
private void Awake() { Instance = this; Initialize(30); }
IEnumerator DestroyGoods(GameObject returnThis) { yield return(new WaitForSeconds(3f)); GoodsCupObjectPool.ReturnObject(returnThis); }