Okay guys, I’m totally stumped on this one…I have a game on the AppStore called “Rolly”. The point of the game is to get to point a to point b as quickly as possible. Obstacles include turrets, bomb droppers, harmful surfaces, etc. So, about a month ago, I implemented a “bullet time” feature and it worked well. Code below:
function OnGUI () {
if (GUI.Button (Rect (0,280,120,40), "Bullet Time")) {
if (Time.timeScale == 1) {
Time.timeScale = 0.2;
}
else {
Time.timeScale = 1;
}
Time.fixedDeltaTime = 0.02 * Time.timeScale;
}
}
That worked great. It got what I wanted done and didn’t drop the frame-rate dramatically on an iPhone. Then, there’s the pause button I had in the same scene that still worked with the Bullet Time button:
var savedtimeScale : float;
var pause = false;
var ButtonSay = "Pause";
function OnGUI()
{
if (GUILayout.Button(ButtonSay))
{
if (!pause)
{
savedtimeScale = Time.timeScale;
Time.timeScale = 0.0;
ButtonSay = "UnPause";
pause = true;
}
else if (pause)
{
Time.timeScale = savedtimeScale;
ButtonSay = "Pause";
pause = false;
}
}
}
So that’s what I HAD and it worked…now I decided to make a more user-friendly and feature-filled pause menu. I replaced the original Pause script with this one:
var doWindow0 = false;
var pause = false;
function OnGUI () {
GUI.color = Color.yellow;
doWindow0 = GUI.Toggle (Rect (0,0,100,50), doWindow0, "Pause.");
if (doWindow0){
GUI.color = Color.white;
GUI.Window (0, Rect (145,50,200,220), DoWindow0, "Pause.");
Time.timeScale = 0.0;
pause = true;
}
else{
Time.timeScale = 1.0;
pause = false;
}
}
function DoWindow0 (windowID : int) {
if (GUI.Button (Rect (25,30,150,40), "Resume")){
doWindow0 = false;
}
if (GUI.Button (Rect (25,100,150,40), "Re-start")){
Application.LoadLevel(PlayerPrefs.GetString("Level"));
}
GUI.color = Color.red;
if (GUI.Button (Rect (25,170,150,40), "Quit")){
Application.LoadLevel ("Menu");
}
}
Then, things went wacky. The pause menu worked perfectly. However, the bullet time mode now doesn’t and I can’t figure out why. Whenever I try to enter bullet time, it just freezes the ball that you control but everything else is still functional (pause menu, etc.). I’m thinking it has something to do with the conflicting timescales?
Can someone please help? I’m really stuck and have been working all day trying to fix this.