void TakeItem(Robot r) { foreach (string item in acceptedItems) { if (r.holdingObjectName.Equals(item)) { holdingObjectName = r.holdingObjectName; r.holdingObjectName = ""; GameObject holdingObject = GameObject.Find(holdingObjectName); holdingObject.GetComponent<Obtainable>().used = true; if (holdingObjectName.Equals(killItemName)) { isAlive = false; gameObject.transform.Rotate(new Vector3(0.0f, 0.0f, -90.0f)); // FALL DOWN. r.IncrementNumCompletedTasks(); } else { r.IncrementNumCompletedTasks(); } Destroy(holdingObject); } } }