private void OnCollisionEnter(Collision collision) { if (collision.collider.tag == "obstacle") { transform.root.GetComponent <SpringJoint>().connectedBody = null; movement mov = GameObject.FindGameObjectWithTag("Player").GetComponent <movement>(); if (mov.numberOfCartsAttached > index) { mov.numberOfCartsAttached = index; Camera.main.GetComponent <screenShake>().Shake(); mov.lives.text = index.ToString(); if (index == 0) { mov.end(); } } } }