Hi guys,
I’ve been using a clock script by TJB, it allowes me to create events at certain time of day, but I ran into problems the minute I tried to extend it with “my own” code. This is what I’m using atm.
var lastChange = 0.0;
var timeSpeed = 0.00;
var hour = 0;
var minutes = 0;
var Hour = "24";
var SpawnNight: Transform;
function Update () {
if (Time.time - lastChange > timeSpeed) {
minutes++;
if (minutes == 6) {
minutes = 0;
hour++;
if (hour == 24) {
if (Hour == "25") {
} else {
newDay();
}
}
if (hour == 24) {
hour = 0;
}
}
if (hour == 5) {
if (hour == "6") {
} else {
killEnemy();
}
}
lastChange = Time.time;
}
}
function OnGUI () {
GUILayout.Label(hour.ToString() + ":" + minutes.ToString() + "0");
}
function newDay () {
// whatever happens on a new day
// Instantiates copies of prefab each 2 units apart from each other
var prefab : Transform;
for (var i : int = 0;i < 1; i++) {
Instantiate (SpawnNight);
}
}
function killEnemy() {
// whatever happens at 5 in the morning
Destroy(GameObject.FindWithTag("Enemy"));
}
}
What I’m trying to achieve is that at 5 o’ clock in the morning all objects tagged with “Enemy” is destroyed, but what happens is that only some BONES in the last Enemy spawned is removed. I’ve tried tagging every part of the gameobject, but nothing works. Does anyone know how to fix this?