private void OnCollisionExit(Collision collision) { GameObject temp = collision.gameObject; if ((!temp.Equals(scale)) && (!temp.Equals(scaleSurface))) { MassAttach tma = temp.GetComponent <MassAttach>(); if (tma != null) { scaleSurface.GetComponent <MeasureMass>().Pop(temp); Destroy(tma); } } }
/*Called when an object stops colliding with the scale surface * if the object has a Mass Attach script remove the object from the list of objects to be measures * then remove the Mass Attach script from the object*/ private void OnCollisionExit(Collision collision) { //Store the colliding object in temp GameObject temp = collision.gameObject; //Get the colliding objects Mass Attach script MassAttach tma = temp.GetComponent <MassAttach>(); //If the tma is not null that means that the script was stored successfully so remove it from the object if (tma != null) { Pop(temp); Destroy(tma); } }