private void combine() { if (rightHandItem == null || leftHandItem == null) //not holding something in both hands. we're done. { return; } SimpleObject rightSimple; SimpleObject leftSimple; try{ rightSimple = (SimpleObject)rightHandItem; leftSimple = (SimpleObject)leftHandItem; }catch (InvalidCastException) { //one of these things is not a simple object, so not combineable. we're done. playSound_error(); return; } GameObject newObject = rightSimple.combine(leftSimple); if (newObject == null) { playSound_error(); return; } Destroy(leftHandItem.gameObject); Destroy(rightHandItem.gameObject); ComplexObject newItem = (ComplexObject)newObject.GetComponent(typeof(ComplexObject)); newItem.pickup(rightHand); rightHandItem = newItem; playSound_poof(); }