- Home /
Menu and Difficulty setup
In the attached files is a very simple project setup which contains a ground plane and a prefab"Cube" The speed of the cube changes based on the level (easy, medium, or hard) chosen by the player. I was wondering how do I control the difficulty the player chooses to play.
Right now when the game is run the menu pops up as expected but the game starts playing in the background. I don't want the game to start until the player has chosen the difficulty. From there, based on the difficulty chosen it will change the value in the variable which controls the speed of the cube. I was wondering if someone could help me get this properly set up in its most simplest form. The menu and everything is already setup as well as the scene in the attached files.The player chooses the setting, then the menu disappears and the games starts with the variable set with the correct speed (see comments in attached file). That's what I'm looking for help on. I hope you guys can help.
Thanks Johnlink text
For not playing the game while in the menu, you could have everything waiting for the menu to be cleared by using a boolean, or have the menu in a separate scene, or you could freeze time.
Personally I would consider a boolean first (but you have to apply it to all scripts, or have all the scripts listen to wait for the bool to become true), next having a separate scene for the menu. Freezing time is more tricky, but I don't have much experience with this, suffice to say I know Update and OnGUI still run. And you don't want to put all your code in FixedUpdate, that is really meant to be used very $$anonymous$$imally, and only for physics based stuff. This can be tested with
function Start () {
Debug.Log("Start is Running");
}
function Update () {
Debug.Log("Update is Running");
if (Input.Get$$anonymous$$ouseButtonUp(0))
Time.timeScale = 0.0;
if (Input.Get$$anonymous$$ouseButtonUp(1))
Time.timeScale = 1.0;
}
function FixedUpdate () {
Debug.Log("FixedUpdate is Running");
}
function OnGUI () {
Debug.Log("OnGUI is Running");
}
For the difficulty, have the buttons return an int based on choice to set the cube with (reading back this part is working ok, yes?)