Question by
importguru88 · Aug 13, 2016 at 11:25 PM ·
scenescene-loadingscorescenestimer-script
How do I make scenes switch properly c#
I am having problem . I trying to make the scene switch base on time . I can't get it to work . What trying to do is see if the timer check for the score when it reaches zero . The player has to score a require amount of points . I will you an example . If I have the score set 100 points ... the timer should be checking to see if I had score the points when the timer reaches zero . If the player has score the require point then the next plays . I got the scene to switch but the problem I am having it's going back to the same level . The script is focus is on that . 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 string nextScene = "FY"; // change this value to what you want
void Update ()
{
if (myClock.m_leftTime <= 0)
{
if ((ScoreManagerScript.score >= scoreToReach) && (nextScene != "FY"))
{
SceneManager.LoadScene(nextScene);
}
else
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
}
}
Comment