a1001
New Member
Posts: 7
Posts: 7
|
Post by a1001 on Sept 14, 2015 15:53:15 GMT
Hi there , first of all thanks for this great asset . I would like to get the advice/recommendation regarding the best possible way to achieve what i want to do ! Here is what i want to do : 1) Place spawn points across the map ( its pretty big map and has rooms ) 2) only enable the spawnpoints of particular room once player is in that room 3) randomly spawn objects from random spawn points inside that room ( instead of spawning enemies from all the spawn points i want them to randomly spawn enemy from those spawn points) Any help is appreciated  EDIT : just now i came across a bug , sometimes i get this Debug.Log in my console saying "cannot spawn the "enemy" prefab ? any idea why this is happening ?
|
|
|
Post by DarkTonic Dev on Sept 15, 2015 0:34:55 GMT
That doesn't sound like an error. You should turn on Logging for the Pool Boss game object. I believe it will say something like "The Transform 'Enemy' has no available clones left to Spawn in Pool Boss. Please increase your Preload Qty, turn on Allow Instantiate More or turn on Recycle Oldest (Recycle is only for non-essential things like decals)."
It will tell you what to do.
All spawners are active by default (Active Mode dropdown at top). You can also make them active based on the value of a World Variable (and manipulate that World Variable when the player enters an area with a trigger), or you could make their game objects inactive during times they aren't supposed to spawn.
Each spawner is unaware of any other spawners and will do its own thing, so if you want random spawn points, you'll need to code that yourself.
|
|
|
Post by A10011 on Sept 15, 2015 7:51:04 GMT
So if I make a script whch puts all spawneds into array and randomly enable disable them will it cause prob with cgk ? Or the spawners will wrk normally when they will get activated
|
|
|
Post by DarkTonic Dev on Sept 15, 2015 15:31:46 GMT
It should work fine. If it does not, let me know and I'll think about a way to make it possible.
|
|
a1001
New Member
Posts: 7
Posts: 7
|
Post by a1001 on Sept 16, 2015 22:31:56 GMT
Hi there ,
I think i now need some help am facing lil problem
using UnityEngine; using System.Collections;
public class spawnHandler : MonoBehaviour {
public GameObject[] SpawnPoints;
int i; int j;
// Use this for initialization void Start () {
} // Update is called once per frame void Update () {
}
void OnTriggerEnter (){
i = Random.Range(0,SpawnPoints.Length); j = Random.Range (0, SpawnPoints.Length);
SpawnPoints [*i*].SetActive (true); SpawnPoints[j].SetActive(true);
}
void OnTriggerExit () {
SpawnPoints [*i*].SetActive (false); SpawnPoints [j].SetActive (false);
}
}
is the script i am using ,
What i have done is
1) made couple gameobjects named SpawnerGroup 2) attached script to it
3) dragged and dropped syncro spawners on the gameobject array list
now when i hit play , it go collide with triggers , it enables the spawners but nothing is spawned
if i tap out of play mode > enable the syncro spawners > then hit play > game starts > and syncro spawner spawns the enemy
Also some feature requests :
-- Random Spawn time delay options ( which spawns object after some random time ) -- Limit to maximum spawned objects ( say if i set maximum 10 enemies once spawners spawned 10 enemies they wont spawn anything till those 10 enemies are reduced to anything less than 10 )
PS : just wrote the array index as [*i*] because when trying to write i in brackets it was making rest of the code italics
|
|
|
Post by DarkTonic Dev on Sept 17, 2015 0:50:15 GMT
It's easier for me to add the feature than to troubleshoot what's going on with your code. I've added "make it possible to use less than all spawners with each wave" to the roadmap. The request about limit maximum spawned objects was already on the roadmap. Please elaborate on what you want for the random time delay one. That may be quite difficult actually. Roadmap thread is here for reference: darktonic.freeforums.net/thread/94/feature-roadmap-core-gamekit-suggest
|
|
a1001
New Member
Posts: 7
Posts: 7
|
Post by a1001 on Sept 17, 2015 9:35:52 GMT
It's easier for me to add the feature than to troubleshoot what's going on with your code. I've added "make it possible to use less than all spawners with each wave" to the roadmap. The request about limit maximum spawned objects was already on the roadmap. Please elaborate on what you want for the random time delay one. That may be quite difficult actually. Roadmap thread is here for reference: darktonic.freeforums.net/thread/94/feature-roadmap-core-gamekit-suggestright now cgk is acting like a horde spawner ( u can spawn x number of items in x seconds ) you can configure waves but still its same concept ( x number of thing in x number of time ) what happens is , if i am trying to make a game in which i am in a room and want enemies to spawn 1 by 1 randomly from random spawners it wont work . Right now i have my spawners set to Spawn ( Min/Max) : 1 ,, so every spawner indeed spawns 1 enemy and i have set the repeat wave to endless so they keep spawning 1 - 1 enemy right now spawners keep spawning like crazy , so a Limit feature on spawned objects be great so we can tell if there are 5 things spawned dont spawn anything else . Also another problem is the delay is fixed , player knows 1 enemy will spawn after x number of seconds ( say 2 seconds ) so he knows 1 enemy comes every 2 seconds . so basically all spawners spawn enemies every 2 seconds . So a feature in which we can set a Random Range of say 1-8 seconds for example , so now spawners will choose randomly between 1-8 seconds and spawn things based on that But adding features will probably take time , and am short on time  i purchased the asset thinking it will be a great deal to get spawning system with poolboos ( earlier i was just going to go with poolboos ) but seems i need to wait abit ohwell . I might have to make own spawning system using just poolboss now i think =/
|
|
|
Post by DarkTonic Dev on Sept 17, 2015 15:30:22 GMT
The random delay thing may be difficult based on how they currenctly work. I'll put it on the roadmap anyway and take a stab when I have time.
The "use random spawner" thing should be easy though, I will probably crank that out quite soon.
|
|
a1001
New Member
Posts: 7
Posts: 7
|
Post by a1001 on Sept 18, 2015 3:24:37 GMT
The random delay thing may be difficult based on how they currenctly work. I'll put it on the roadmap anyway and take a stab when I have time. The "use random spawner" thing should be easy though, I will probably crank that out quite soon. ok so i made a script which handles my spawning now , choses 2 points randomly from assigned spawnpoints ( 4 ) , and randomly chooses the delay ( between min and max ) do you have any recommendation ? or the code looks fine ( performance wise too ? ) . Also i will keep eye out for update on CGK for future ^_^ Thanks for all the help Cheers
using UnityEngine; using System.Collections; using Darktonic.CoreGameKit;
public class spawnSystem : MonoBehaviour {
public Transform Enemy; public GameObject[] spawnPoints;
public float minDelay; public float maxDelay;
public float spawnLimit;
public bool readyToSpawn; public bool debug;
int i; int j;
float delayi; float delayj;
float oldDelayi; float oldDelayj;
float spawnedEnemies;
// Use this for initialization void Start () {
startSpawning (); } // Update is called once per frame void Update () {
if (readyToSpawn == true) {
if (spawnedEnemies < spawnLimit) { delayi = delayi - Time.deltaTime * 1 / Time.timeScale; if (delayi <= 0) { PoolBoss.SpawnInPool (Enemy, spawnPoints [i].transform.position, spawnPoints [i].transform.rotation); spawnedEnemies++; delayi = oldDelayi; } delayj = delayj - Time.deltaTime * 1 / Time.timeScale; if (delayj <= 0) { PoolBoss.SpawnInPool (Enemy, spawnPoints [j].transform.position, spawnPoints [j].transform.rotation); spawnedEnemies++; delayj = oldDelayi; } } } }
void OnTriggerEnter(Collider Other) { if (Other.tag == "Player") {
startSpawning();
} }
void OnTriggerExit(Collider Other){
if (Other.tag == "Player") {
stopSpawning ();
} }
public void startSpawning() {
i = Random.Range (0, spawnPoints.Length); j = Random.Range (0, spawnPoints.Length);
if ( j == i ) {
j++; if ( j == spawnPoints.Length - 1){
j = i - 1; } }
spawnPoints [i].SetActive (true); spawnPoints [j].SetActive (true);
delayi = Random.Range (minDelay, maxDelay); delayj = Random.Range (minDelay, maxDelay);
oldDelayi = delayi; oldDelayj = delayj; readyToSpawn = true;
if (debug == true) { print (i); print (j);
print (delayi); print (delayj); }
}
public void stopSpawning () {
spawnPoints [i].SetActive (false); spawnPoints [j].SetActive (false);
readyToSpawn = false;
}
}
|
|
|
Post by DarkTonic Dev on Sept 18, 2015 4:53:35 GMT
Looks fine. I think you could have done without writing so much code though. Triggered Spawner wave could receive a Custom Event and have 4 Wave Offsets (which are already chosen from randomly each time) for the 4 spawn positions. Then you could just fire the Custom Event each time you want to spawn one. That way you still get all the other Triggered Spawner controls as well. Either way, you should be good 
|
|