- Home /
when game is resumed it would not be resumed from where it was paused ?
i have pause code in my unity and i also created GUI button in the same code to resume the game.
when i originally start the game for first time my character is walking in scene but when i resume after pause it would not walk in scene.
i do not seem to understand what is the reason behind it. if someone can explain me how to eliminate that error that would be big help.
I have attached the part of code where i have can resume game (start button) and quit game when game is paused.
Thanks in advanced
else if (gamePausedBool == true) { GUI.skin = skin ; if(GUI.Button(new Rect(Screen.width * .35f,Screen.height * .10f,300,100), "Start Game")) { Application.LoadLevel("Game"); } if(GUI.Button(new Rect(Screen.width * .35f,Screen.height * .35f,300,100),"Quit Game")) { Application.Quit(); }
This is not enough info for us to go on at all. We need to see the code when the game is paused. We need context here. Explain to us what steps are being taken to pause and resume your game. $$anonymous$$ore info, more info.
well the thing is pause code is working. so when i pause game it stops the game but real problem is when i say start game again it would just remove the menu screen from screen and load level but i am not able to move anything from that scene it stay frezzed even after starting game again.
Answer by Maui-M · Feb 07, 2014 at 04:35 PM
I think your issue is using Application.LoadLevel. Instead of using that you should just stop your current game code from running in Update() which would give it the appearance of pausing.
function OnGui(){
//The rest of your OnGUI code
else if (gamePausedBool == true)
{
GUI.skin = skin ;
if(GUI.Button(new Rect(Screen.width * .35f,Screen.height * .10f,300,100), "Resume Game")) {
gamePausedBool = false;
}
if(GUI.Button(new Rect(Screen.width * .35f,Screen.height * .35f,300,100),"Quit Game")) {
Application.Quit();
}
}
}
function Update(){
if (gamePausedBool == false){
// Run your normal game logic here
// This will not run if the game is paused
}
}
Your answer
Follow this Question
Related Questions
Hide the ImageTraget in Real world 0 Answers
Android Development; How to use SDK manager! 1 Answer
drawing a line following an object 3 Answers
Problem with Snake Game(input help) 1 Answer