Question by
importguru88 · Aug 14, 2016 at 10:29 AM ·
scene-loadingscene-switchingscenes
How do I change scene with by a score lesser time based / problem scene wont switch to the right scene
The score I have reach is in the if statement. The Issue I am having is not it switches to the wrong scene . The script is calling what is in the if statement. I just want to do a score less from the score reach number when timer reach zero . The score less is suppose to transition into a restart scene when timer reach zero. I have the code in the else if statement:
Here is my code :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class TestScript : MonoBehaviour
{
public MyClockScript myClock;
public ScoreManagerScript scoremanager;
public int scoreToReach = 99; // change this value to what you want
public int leastscore = 50;
public string nextScene = "FY"; // change this value to what you want
public string restartscene = "gy";
void Update ()
{
if (myClock.m_leftTime <= 0)
{
if ((ScoreManagerScript.score >= scoreToReach) && (nextScene != ""))
{
SceneManager.LoadScene(nextScene);
}
else if ((ScoreManagerScript.score >= leastscore) && (restartscene != ""))
{
SceneManager.LoadScene(restartscene); //enter else if code here
}
}
else
{
;
}
}
}
Comment