void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag == "Allied") { targetShipScript = coll.gameObject.GetComponentInParent <SharedSpecsScript> (); targetShipScript.healthPoints -= Random.Range(1f, 3f); Instantiate(explosionAni, transform.position, transform.rotation); Destroy(gameObject); } }
void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag == "Enemy") { Instantiate(explosionAniMissile, transform.position, transform.rotation); targetScript = coll.gameObject.GetComponent <SharedSpecsScript>(); targetScript.healthPoints -= Random.Range(80f, 120f); Destroy(gameObject); } }
void Awake() { thisSpriteRenderer = gameObject.GetComponent <SpriteRenderer> (); parentScript = GetComponentInParent <SharedSpecsScript> (); }