Hey there guys, I’ve never had any luck what so ever having a properly working Pause Menu, Inventory Menu, or anything else in relation to having a Visible Unlocked cursor…
The reason being is that the Cursor will never ever ‘STAY’ visible it either disappears very shortly after popping up and returns back to moving the camera, or it stays visible but as soon as i click anywhere on the screen it returns to the centre.
I am using Brakey’s Inventory System, but as always with using other peoples scripts and what have you… It’s outdated and is looking for the MouseLook Component… which as far as i know has not been in action on the FPC for the past 2 years… and if so I’ve never seen it.
The exact thing I am trying to achieve is…
Once ‘Tab’ is pressed, the game is completely Paused. (Sounds Paused, Time Scale 0, Camera cannot move when paused, the mouse is ‘CONSTANTLY’ available while paused, even after clicking on the game screen.)
I have provided a video to help provide a better resolution.
(If the above video link does not work, it may still be Uploading)
If you watched the video you may see the errors within the code, but if not, here is the InvPauseGame.js from Brakeys Inventory System.
#pragma strict
#pragma downcast
var pauseGame = true; //Do we want to pause/unpause the game?
var disableMouseLookComponent = true; //Do we want to enable/disable the MouseLook component?
//These two variables are used when disabling/enabling the MouseLook component.
var ThePlayer : Transform;
var TheCamera : Transform;
var lockUnlockCursor = true; //Do we want to lock/unlock the mouse cursor?
private var lookAround01 : Behaviour;
private var lookAround02 : Behaviour;
@script AddComponentMenu ("Inventory/Other/Inv Pause Game")
function Awake ()
{
if (disableMouseLookComponent == true)
{
if (ThePlayer != null && TheCamera != null)
{
if (ThePlayer.GetComponent("MouseLook") != null || TheCamera.GetComponent("MouseLook") != null)
{
lookAround01 = ThePlayer.GetComponent("MouseLook");
lookAround02 = TheCamera.GetComponent("MouseLook");
}
else
{
disableMouseLookComponent = false;
}
}
else
{
disableMouseLookComponent = false;
}
}
}
function PauseGame (pauseIt : boolean)
{
//Locking the cursor
if (lockUnlockCursor == true)
{
if (pauseIt == true)
{
Screen.lockCursor = false;
}
else
{
Screen.lockCursor = true;
}
}
//Pausing the game
if (pauseGame == true)
{
if (pauseIt == true)
{
Time.timeScale = 0.0;
Time.fixedDeltaTime = 0.02 * Time.timeScale;
}
else
{
Time.timeScale = 1.0;
Time.fixedDeltaTime = 0.02 * Time.timeScale;
}
}
//Disabling the MouseLook component
if (disableMouseLookComponent == true)
{
if (ThePlayer != null && TheCamera != null)
{
if (pauseIt == true)
{
lookAround01.enabled = false;
lookAround02.enabled = false;
}
else
{
lookAround01.enabled = true;
lookAround02.enabled = true;
}
}
else
{
Debug.LogError("The variables of the 'InvPauseGame' script on '" + transform.name + "' has not been assigned.");
}
}
}