public IEnumerator CreateTextObjects(string text) { FlyingText.addRigidbodies = true; var textObjects = FlyingText.GetObjectsArray(text); foreach (var textObject in textObjects) { textObject.GetComponent <Renderer>().enabled = false; textObject.GetComponent <Rigidbody>().useGravity = false; } foreach (var textObject in textObjects) { yield return(new WaitForSeconds(appearanceInterval)); textObject.AddComponent <TextObjectController>().Initialize(); } }
IEnumerator ExplodeText() { acceptInput = false; CancelInvoke("BlinkCursor"); Destroy(textObject); FlyingText.addRigidbodies = true; var letters = FlyingText.GetObjectsArray(enteredText, new Vector3(-7, 6, 0), Quaternion.identity); foreach (var letter in letters) { letter.GetComponent <Rigidbody>().useGravity = false; letter.GetComponent <Rigidbody>().AddTorque(new Vector3(Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f)) * 10.0f); letter.GetComponent <Rigidbody>().AddExplosionForce(390.0f, new Vector3(0, 1, 11), 15.0f); } yield return(new WaitForSeconds(5)); foreach (var letter in letters) { Destroy(letter); } InitializeText(); }