Unlocking mouse when load certain scene

So I am making this fps, which obviously has the mouse look feature. But I am a beginner in Unity, and I do not know how to script this particular scheme.

I have my game load the GameOver scene when the player dies. I do that by making a gamecontroller, an when the player dies, the player sends out a message to the gamecontroller, and when that happens, the gamecontroller loads the GameOver scene. When the GameoVer scene loads, a BGM plays. After the BGM stops playing, or the player clicks his/her mouse or any key, loads the main menu. The problem is, when the game loads the GameOver scene, the mouse still does not display.

I want an extension to the gamocontroller script, which now only has the ability to load the Gameover level. The script I have now is displayed below. (The gameover scene is loaded in the function FPSmort(); section.

private var objectives : int;

function OnEnableObjective() {
    objectives++;
}

function OnDisableObjective() {
    objectives--;
    if (objectives == 0)
        SendMessage("OnObjectives");
}

function OnObjectives() {
    Application.LoadLevel("LPF");
}

function FPSmort()
{
    Application.LoadLevel("GameOver");
}

1 Answer

1

set Screen.lockCursor to true or false as you see fit :)

if you wanted you could also adjust the MouseLook script to only work when the cursor is locked, so when viewing the menu they're not looking all over the place