- Home /
Question by
The-Gaming-Seed · Apr 13, 2017 at 12:52 PM ·
sceneplayerprefsvariablesstaticsaving
How do i imports my variable to another variable and save it with PlayerPrefs?
I have a variable called 'Timer' and the timer goes down each section. I want to also take the time to another script wich will save when the character goes on the trigger. Like this:
public float The_Timer;
private Text Timer;
private bool The_time_is_active = true;
public string Scene_name;
void Start()
{
Timer = GetComponent<Text>();
}
public void Update()
{
if (The_time_is_active)
{
The_Timer -= Time.deltaTime;
Timer.text = The_Timer.ToString ("f0");
if (The_Timer <= 0) {
Application.LoadLevel (Scene_name);
}
}
}
and
void OnTriggerEnter(Collider other)
{
PlayerPrefs.SetFloat ("Time", Lose_Time.The_Timer);
}
I have tried setting The_Timer to a static but when I do, the time goes down to 0 and it's not public.
I've tried adding void OnTriggerEnter on the first script but I get a constant error say the object is not set to an intense of an object. I've assigned the text but when the game starts it says it's not assigned and keeps on giving me the error.
Comment