void OnCollisionEnter2D(Collision2D theCollision) { if (theCollision.gameObject.name.Contains("rhino")) { theCollision.gameObject.GetComponent <RhinoSpriteCatch>().ChangeIt(); theCollision.gameObject.GetComponentInParent <SpeedRinoParent>().enabled = false; theCollision.gameObject.GetComponent <PlayerController>().ShowLose(); } else if (theCollision.gameObject.name.Contains("hunter")) { //Destroy(this.gameObject); HunterScript hunterScript = theCollision.gameObject.GetComponent("HunterScript") as HunterScript; hunterScript.Crash(); canvas.GetComponent <UIController>().AddScore(); } }
void OnCollisionEnter2D(Collision2D theCollision) { if (theCollision.gameObject.name.Contains("hunter")) { //Destroy(this.gameObject); HunterScript hunterScript = theCollision.gameObject.GetComponent("HunterScript") as HunterScript; hunterScript.Crash(); GameObject crashed = transform.Find("crashed").gameObject; crashed.GetComponent <AudioSource> ().enabled = true; crashed.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1); canvas.GetComponent <UIController>().AddScore(); } else if (theCollision.gameObject.name.Contains("rhino")) { crashed.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1); canvas.GetComponent <UIController>().AddScore(); GameObject Canvass = GameObject.Find("MyCan").gameObject; Canvass.GetComponent <UIController>().AddScore(); } }