Okay so… a little bit baffled on an issue of instantiaton. Not sure that’s a word but I’m going with it.
Here’s the basics of the deal:
I have a code designed to allow the user to select how many of a certain structure to build. Logically, it seems as though they should all be instantiated at once, but rather progressively over a period of time, right? So, here’s the breakdown:
- GUI buttons control how many to build.
- The script accesses the master clock script to synchronize time.
- Theoretically, the script below should instantiate a new object of type at regular intervals, right? The problem is, it doesn’t actually instantiate anything…
var targetDayNext : float = 0;
var startDayLF : float = 0;
var daysCounter : float = 0;
function BuildLightFactoryCountdown () {
startDayLF = GalMap.GetComponent(MainScreenClock).days;
targetDayNext = startDayLF + 3.0;
if (daysCounter > targetDayNext) {
Invoke ("BuildLightFactory", 0.0);
}
}
function BuildLightFactory () {
var lightFactory : GameObject = Instantiate(lightFactory);
lightFactory.transform.parent = transform;
startDayLF = 0;
targetDayNext = 0;
if (lightFactoryBuildCounter > 0) {
Invoke ("BuildLightFactoryCountdown", 0.0);
}
}
function Update () {
daysCounter = GalMap.GetComponent(MainScreenClock).days;
}