void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Laser") { // spawn the prefab explosion on the screen at the asteroid position. Instantiate(_asteroidExplosionFab, transform.position, Quaternion.identity); // when the laser collides with the // asteroid destroy the laser. Destroy(other.gameObject); _explosionSound.Play(); // call the method to start spawning. // after asteroid is destroyed. _spawnManager.StartSpawning(); // Destroy asteroid Destroy(this.gameObject); } if (other.tag == "Player") { _explosionSound.Play(); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Laser") { Instantiate(_explosionPrefab, transform.position, Quaternion.identity); Destroy(other.gameObject); _spawnManager.StartSpawning(); Destroy(this.gameObject, 0.25f); } }
private void OnTriggerEnter2D(Collider2D other) { Debug.Log("Hit: " + other.transform.name); if (other.tag == "Laser") { Instantiate(_explosionAnim, transform.position, Quaternion.identity); Destroy(other.gameObject); _spawnManager.StartSpawning(); Destroy(GetComponent <Collider2D>()); Destroy(this.gameObject, 0.25f); } }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Laser") { Instantiate(_explosion, this.transform.position, Quaternion.identity); _spawnManager.StartSpawning(); Destroy(this.GetComponent <Collider2D>()); Destroy(other.gameObject); Destroy(this.gameObject, 0.2f); } _audio.Play(); }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Projectile") { Destroy(other.gameObject); _asteroidLives--; if (_asteroidLives == 0) { Instantiate(_explosionPref, this.transform.position, Quaternion.identity); _uiManager.UpdateLevel(1); _spawnManager.StartSpawning(); _uiManager._instructionsImg.gameObject.SetActive(false); Destroy(this.gameObject, 0.25f); } } }
void Update() { _horizontalInput = Input.GetAxis("Horizontal"); _verticalInput = Input.GetAxis("Vertical"); ScreenWrapping(); //Disable reverse input if (_verticalInput < 0) { _verticalInput = 0; } if (Input.GetKeyDown(KeyCode.Space) && Time.time > _canFire) { _spawnManager.StartSpawning(); _uiManager.StartGame(); FireBullet(); _audioSource.Play(); } }
// Use this for initialization void Start() { transform.position = new Vector3(0, 0, 0); _uI_Manager = GameObject.Find("Canvas").GetComponent <UI_Manager>(); if (_uI_Manager != null) { _uI_Manager.UpdateLives(_health); } _gameManager = GameObject.Find("GameManager").GetComponent <GameManager>(); _spawnManager = GameObject.Find("Spawn_Manager").GetComponent <Spawn_Manager>(); if (_spawnManager != null) { _spawnManager.StartSpawning(); } _audioSource = GetComponent <AudioSource>(); _hitCount = 0; }