void OnTriggerEnter2D(Collider2D collider) { LaserControl projectile = collider.gameObject.GetComponent <LaserControl> (); if (projectile) //projectile != null { Debug.Log("Hit by a projectile"); health -= projectile.Hit(); if (health <= 0) { Die(); } } }
void OnTriggerEnter2D(Collider2D collider) { LaserControl projectile = collider.gameObject.GetComponent <LaserControl> (); if (projectile) //projectile != null { Debug.Log("Hit by a projectile"); health -= projectile.Hit(); if (health <= 0) { AudioSource.PlayClipAtPoint(deathSound, transform.position, 1f); SmokeWhenDie(); Destroy(gameObject); scoreKeeper.Score(scoreValue); } } }