void LeaveCharacter(bool _disableAsWell) { //Later we will check which player activated this command. For now, let's set to player 1 GameObject ghostInControl = GhostManager.GetGhost(1); GhostBehaviour ghostScript = ghostInControl.GetComponent <GhostBehaviour>(); //save a reference to his script ghostInControl.transform.position = transform.position; //set ghost to where possessed enemy was ghostScript.StopMoving(); //stop character's velocity Camera.main.transform.parent = ghostInControl.transform; //set camera's parent back to ghost ghostInControl.layer = frontLayer; //send ghost to front layer if he isn't already if (ghostInControl.transform.localScale.x > 0 && transform.localScale.x < 0 || ghostInControl.transform.localScale.x < 0 && transform.localScale.x > 0) //if player is facing the other direction from ghost { ghostScript.FlipSprite(); //flip ghost sprite } ghostInControl.renderer.enabled = true; //set his renderer back on so he can be seen ghostScript.controlState = ControlState.PlayerControlled; //player can control the ghost again Destroy(gameObject); //ghost kills the character he possessed when he's done if (_disableAsWell) //if the disable as well boolean is set to true { ghostScript.controlState = ControlState.Disabled; //disable the ghost. this is ideal for when he reaches the goal } }