void disableGhosts() { foreach (GameObject ghost in ghosts) { GhostScript script = ghost.GetComponent <GhostScript>(); if (script != null) { script.StopMoving(); } } //special hacky fix for up-down ghosts :/ GameObject[] upDownGhosts = GameObject.FindGameObjectsWithTag("upDownGhost"); foreach (GameObject ghost in upDownGhosts) { upDownGhost script = ghost.GetComponent <upDownGhost>(); if (script != null) { script.upDownGhostsMoving = false; } } //special hacky fix for up-down ghosts :/ GameObject[] squareGhosts = GameObject.FindGameObjectsWithTag("squareGhost"); foreach (GameObject ghost in squareGhosts) { squareGhost script = ghost.GetComponent <squareGhost>(); if (script != null) { script.squareGhostMoving = false; } } GameObject upDownDoor = GameObject.FindGameObjectWithTag("upDownDoor"); if (upDownDoor != null) { upDownDoor doorScript = upDownDoor.GetComponent <upDownDoor>(); if (doorScript != null) { doorScript.upDownDoorMoving = false; } } }