private static void TakeControlOfPlayer() { Controller c = GameObject.FindObjectOfType <Controller>(); if (!c) { Debug.LogError("Could not find Controller in scene."); return; } FPSChar playerPawn = GameObject.FindObjectOfType <FPSChar>(); if (!playerPawn) { Debug.LogError("Could not find FPSChar in scene."); return; } if (!UnityEditor.EditorApplication.isPlaying) { Undo.RecordObject(c, "Take Control of Player"); } c.TakeControlOf(playerPawn); }
private static void PrepPlayerForGame() { if (UnityEditor.EditorApplication.isPlaying) { Debug.LogError("Can not prep player for game while game is already playing!"); return; } Controller c = GameObject.FindObjectOfType <Controller>(); FPSChar playerPawn = null; if (c) { if (c.ControlledPawn && c.ControlledPawn is FPSChar) { Undo.RecordObject(c, "Prep Player for Game"); playerPawn = c.ControlledPawn as FPSChar; c.ReleaseControl(); } } if (!playerPawn) { playerPawn = GameObject.FindObjectOfType <FPSChar>(); } if (!playerPawn) { Debug.LogError("Could not find FPSChar in scene."); return; } Checkpoint defaultCheckpoint = Checkpoint.DefaultCheckPoint; if (!defaultCheckpoint) { Debug.LogError("Could not find Default Checkpoint in scene."); return; } Undo.RecordObject(playerPawn.transform, "Prep Player for Game"); Util.MoveTransformToTarget(playerPawn.transform, defaultCheckpoint.transform); }
private void SkipIntroSequence() { bool skipIntroFailed = false; IntroHelper intro = FindObjectOfType <IntroHelper>(); Controller playerController = FindObjectOfType <Controller>(); FPSChar playerPawn = FindObjectOfType <FPSChar>(); if (playerController) { if (playerController.ControlledPawn == playerPawn) { Debug.Log("[DebugMenu] Already past intro sequence."); return; } } else { Debug.LogError("[DebugMenu] Failed to skip intro sequence, no player controller found!"); skipIntroFailed = true; } if (!playerPawn) { Debug.LogError("[DebugMenu] Failed to skip intro sequence, no player pawn found!"); skipIntroFailed = true; } if (!intro) { Debug.LogError("[DebugMenu] Failed to skip intro sequence, no IntroHelper found!"); skipIntroFailed = true; } if (skipIntroFailed) { return; } intro.FinishFlying(); intro.gameObject.SetActive(false); }