Active and Inactive Spawn Points
I'm very new to coding and Unity. I'm trying to figure out the best way to set up a system of active and inactive spawn points in my game.
I have a list of 165 different points and I have a matrix in 10 minute blocks. So Group1 is active from :00-:09 minutes every hour, Group2 from :10-:19 minutes every hour, etc...
I'm writing 2 scripts, one to manage the spawning that I'm calling the "Spawn Manager" and then a Game Manager. My thought was that the SM would handle the task of determining which points were active at any given time. Then, from the ones that were active the GM would handle the task of actually choosing which ones to use. I don't intend to spawn at every active point, just a yet to be determined percentage of them.
My question is what is the best way to structure this? I have considered 2 approaches.
1) putting the groups into 6 enums and then using an IF statement to determine which group is currently active.
2) creating a data table with the points as rows and the minutes (:00 - :10, etc) as the column headings and then simply "active" or "inactive" in the cells. Then somehow, either through code or SQL, referencing that to know which points were active.
But, I thought there might be a better or more efficient way to do it and that maybe some of you with more experience could offer some advice on the best approach.
Currently I have 6 prefabs and 6 iterations of the following script with different time blocks. The scripts are attached to the corresponding prefabs and it works to make all of the spawn points in the group active. However, as stated above, I don't want 100% of them active, so what I really need to do is for my SM to determine all of the points that are available and pass that information to my GM and then let it decide which points to use.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEngine.Events;
public class Group1 : MonoBehaviour
{
DateTime moment = DateTime.Now;
void Start()
{
int currentMinutes = moment.Minute;
if (currentMinutes >= 00 && currentMinutes <= 09)
{
return;
}
else
{
Destroy(this.gameObject);
}
}
}
`
Your answer
Follow this Question
Related Questions
Accesing enum type from another script 1 Answer
C# naming related enum, private member and public accessor. 2 Answers
Does anyone have any tips on creating a 2.5/3D side scroller shooter? 0 Answers
Which game controller protocol can I use to transfer data from BN055 motion sensor to Unity? 0 Answers
Walk player around Cylinder 0 Answers