Hey! I'm really, really new to all things code, and my game time script was made with a lot of hand-holding from tutorials and friends, and I'm having trouble figuring out where to add the (public int variableIDToSyncWith = _____) in it. Any help would be very much appreciated! I apologize if this is a simple fix ;;
I want to link the variables for minute, hour, day, second, month, and year.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameTimeCalendar : MonoBehaviour
{
private const int TIMESCALE = 45;
private Text clockText;
private Text dayText;
private Text seasonText;
private Text yearText;
public double minute, hour, day, second, month, year;
// Use this for initialization
void Start()
{
month = 1;
day = 1;
hour = 7;
minute = 30;
year = 1890;
clockText = GameObject.Find("Clock").GetComponent<Text>();
dayText = GameObject.Find("Day").GetComponent<Text>();
seasonText = GameObject.Find("Season").GetComponent<Text>();
yearText = GameObject.Find("Year").GetComponent<Text>();
CalculateSeason();
}
Comments
The script doesn't look comprehensive - did you post all of it? Scripts are best copy/pasted in e.g. http://pasteall.org, and links posted here.
By "variableIDToSyncWith", I'm assuming you mean the int variable that's present in the included VariableLinkingExample file.
You need to create a new such variable for each AC Global Variable you wish to sync with. I would recommend just syncing one variable (e.g. Year) succesfully before moving onto the others:
public int yearVariableID;
Place that among your other declared variables, and you'll see it exposed in the Inspector. Set it to the ID value of your AC Global Variable (mind that 'double' is not an option for AC variables - so you'll have to either rely on ints or floats, or convert the value at runtime).
http://pasteall.org/1079101/csharp
Once that's working and you want to sync the others, you don't have to copy the methods again - just update the OnDownload and OnUpload methods with the other "syncID" variables you make.
Thank you for such a fast response, I'll give it another go based on your example!
Is there a way to check a variable every frame? As I have it now, if the npc's path gets interrupted or slowed (either by obstacles, PC interaction, or just me not planning their path well enough) they can miss the variable check and won't move on to the next path.
}