void OnTriggerExit2D(Collider2D other) { // If the projectile leaves the Collider2D boundary... if (other.GetComponent <Rigidbody2D>() == projectile) { // ... call the Reset() function ProjectileControl pj = FindObjectOfType <ProjectileControl>(); pj.Reset(); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Projectile_Asam" || collision.tag == "Projectile_Basa" || collision.tag == "Projectile_Netral") { PlayExplosion(); Destroy(this.gameObject); if (this.gameObject.tag == "Balon_Asam") { ScoreController2 sc = FindObjectOfType <ScoreController2>(); sc.addScore(10); } else if (this.gameObject.tag == "Balon_Basa") { ScoreController2 sc = FindObjectOfType <ScoreController2>(); sc.addScore(10); } else if (this.gameObject.tag == "Balon_Netral") { ScoreController2 sc = FindObjectOfType <ScoreController2>(); sc.addScore(10); } else { ScoreController2 sc = FindObjectOfType <ScoreController2>(); sc.minScore(10); } } if (collision.tag == "Projectile_Asam") { ProjectileControl pj = FindObjectOfType <ProjectileControl>(); pj.Activate_ASAM(false); pj.Reset(); //PauseGame(); } if (collision.tag == "Projectile_Basa") { ProjectileControl pj = FindObjectOfType <ProjectileControl>(); pj.Activate_ASAM(false); pj.Reset(); //PauseGame(); } if (collision.tag == "Projectile_Netral") { ProjectileControl pj = FindObjectOfType <ProjectileControl>(); pj.Activate_ASAM(false); pj.Reset(); // PauseGame(); } }
void Update() { // If we hold down the "R" key... if (Input.GetKeyDown(KeyCode.R)) { // ... call the Reset() function ProjectileControl pj = FindObjectOfType <ProjectileControl>(); pj.Reset(); } // If the spring had been destroyed (indicating we have launched the projectile) and our projectile's velocity is below the threshold... if (spring == null && projectile.velocity.sqrMagnitude < resetSpeedSqr) { // ... call the Reset() function ProjectileControl pj = FindObjectOfType <ProjectileControl>(); pj.Reset(); } }
// Update is called once per frame void Update() { ProjectileControl pj = FindObjectOfType <ProjectileControl>(); pj.Reset(); }