public void Generatematerials(Vector2 hitpoint) { if (available_item_count > 0) { available_item_count -= 1; GameObject item = items[Random.Range(0, items.Count - 1)]; GameObject material = Instantiate(item, hitpoint, Quaternion.identity) as GameObject; Rotator R = material.GetComponent <Rotator>(); if (R != null) { R.Set_rotation_Speed(Random.Range(-item_rotate_speed_min, item_rotate_speed_max)); } UnityFunctions.Move_RB_Random(material.GetComponent <Rigidbody2D>(), item_move_speed_min, item_move_speed_max); if (time_to_live > 0) { Destroy(material, time_to_live); } } }