Easy Question: How to Disable script/Object

Hi guys, ( I use JAVA SCRIPT ) I made a empty game object that contains a " Lock cursor " script ( FPS GAME ) When the player dies and the game goes back to the menu screen.

Problem: Cursor remains still locked and i'am not exactly sure how to disable it ( Newbie )

My game: I'am making my game by using the FPS and Lerpz tutorials and then twisting them for custom use, so its kinda mixxed and has lots of holes, today i was making a menu system and death when you fall off the edge into a box collider.

Just need to be able to use the Cursor to click " Play or Exit " and once play is pressed i need to re-activate it ( Probably the same code but with a true/enabled? )

--- Second Question ---

I would like a " Pause " menu so that it can give you the option to resume or exit, not restart but resume, probably just a GUI overlay?

Thank you so much guys!

  1. go.GetComponent("LockScript").enabled = false;

  2. If all your objects are framerate independent (using time.deltaTime) you can pause the game by setting Time.timeScale = 0; When you paused the game just enable a GUI script that has a resume button which will disable the GUI script and set Time.timeScale back to 1;

Some general comments, not even necessarily Unity specific. Its a good practice to organize, such as using a function to enable all your interactive elements because like in your situation and others, you want to be able to easily enabled and disable some or all interactive interface elements.

Likewise, having a variable such as isUpdating available to pause your updates is helpful. Then, any updateFunction can check the variable and see if the game is paused or not.

Maybe more importantly though is to have your entire updating depend on a set of organized and stored values. This then makes it easier to save these stored values to be able to pause and resume play. This also helps debugging and testing too.

It does not work for me.

Hi I am trying to switch off camera movement from a script that is running costantly because I want to control the camera when I click a Gui button.

I am using go.GetComponent(“LockScript”).enabled = false; and is working perfectly, my question is: what if I wanted to use it in such a way that will not remain off but only when I click the button?

I tried this and I got an error saying enabled is not a member of UnityEngine.Compenent.
But then again I use boo so maybe thats it?

Component class by default does NOT have an enabled variable, so this does not work.