private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.name.Equals("arbol")) { ControlArbol ctr = other.gameObject.GetComponent <ControlArbol>(); if (ctr != null) { ctr.RecibirDisparo(); } Destroy(gameObject); } if (other.gameObject.name.Equals("orc")) { ControlOrco ctr = other.gameObject.GetComponent <ControlOrco>(); if (ctr != null) { ctr.RecibirBala(); } Destroy(gameObject); } }
// Use this for initialization void Start() { ctr = GameObject.Find("orc").GetComponent <ControlOrco> (); }