override public void Execute() { // if I collided with someone, it means my other is someone // destroy my other hasCollided ch = this.gameObject.GetComponentInParent <hasCollided>(); if (ch != null) { GameObject otherObj = ch.other; if (otherObj != null) { Destroy(otherObj); } } }
public void OnCollisionEnter(Collision other) { Debug.Log("collided with " + other.gameObject.name); // both parties' other needs to be recorded hasCollided hc = this.gameObject.AddComponent <hasCollided> (); if (hc != null) { hc.other = other.gameObject; } hasCollided hcOther = other.gameObject.AddComponent <hasCollided> (); if (hcOther != null) { hcOther.other = this.gameObject; } }
override public bool Eval() { bool rval = false; if (ch == null) { if (recipient != null) { ch = recipient.GetComponent <CollisionHelper> (); } } // check for presence of hasCollided flag if (ch != null) { hasCollided hc = recipient.GetComponent <hasCollided> (); if (hc != null) { rval = true; } } return(rval); }