// Use this for initialization void Start() { rb = GetComponent <Rigidbody2D>(); // Create some states stateFree = AddState("Free"); stateCaptured = AddState("Captured"); stateFlushed = AddState("Flushed"); StartState.AddTransition(stateFree).AddTransition(stateCaptured).AddTransition(stateFlushed); // Get a list of all audio sources on children audioSources = new Dictionary <string, AudioSource> (); foreach (AudioSource s in GetComponentsInChildren <AudioSource> ()) { audioSources.Add(s.gameObject.name, s); } Transition(stateFree); // Apply a random velocity to the ball rb.velocity = new Vector2(Random.value * 3, Random.value * 3); rb.AddTorque(Random.Range(1, 3)); }