void OnCollisionStay2D(Collision2D coll) { //on collision with sides of platform, set sideTouch to true if (coll.gameObject.tag == "Platform") { normal = coll.contacts[0].normal; if (normal.x > 0 || normal.x < 0) { sideTouch = true; } } //on collision with code, if f key is pressed, code becomes inactive if (coll.gameObject.tag == "Code") { if (Input.GetKeyDown(KeyCode.F)) { shotsrc.PlayOneShot(editClip, 1.0f); controllerScript.AddScore(100); coll.gameObject.SetActive(false); } //on collision with sides of platform, set sideTouch to true normal = coll.contacts[0].normal; if (normal.x > 0 || normal.x < 0) { sideTouch = true; } } }
void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.tag == "Player" && SceneManager.GetActiveScene().buildIndex >= 8) { SceneManager.LoadScene(1); } else if (coll.gameObject.tag == "Player" && SceneManager.GetActiveScene().buildIndex < 8) { SceneManager.LoadScene(2); } if (coll.gameObject.tag == "Shot") { Destroy(coll.gameObject); Destroy(gameObject); controllerScript.AddScore(150); } }