|
Post by baroquedub on Jan 29, 2017 22:04:44 GMT
I have three Syncro Spawners that each run a single endless wave. I've added a Spawn Increase on each one so that more and more enemies are spawned as time goes on. (out of interest, does this increase the Max or the Min Spawn value or both?)
What I'd like to do is to use a difficulty variable (set elsewhere in the game, in a menu) and use that to increase the possible range of enemies (i.e. change the MaxToSpawn variable programmatically)
i.e. in pseudo code, something only the lines of:
using UnityEngine; using System.Collections; using System.Collections.Generic; using DarkTonic.CoreGameKit;
public class UpdateSpawnerDifficulty : MonoBehaviour {
List<WaveSyncroPrefabSpawner> allSpawners = new List<WaveSyncroPrefabSpawner>();
void Start(){
allSpawners = LevelSettings.SyncroSpawners;
foreach(WaveSyncroPrefabSpawner aSpawner in allSpawners)
{ aSpawner.WaveSettings.MaxToSpawn += GlobalVars.difficulty; // where difficulty is an integer from 1 to 5
}
}
} Is there any way of accessing this variable at runtime? (Sorry, couldn't find it in the API)
|
|
|
Post by DarkTonic Dev on Jan 30, 2017 4:29:50 GMT
Yeah, you can always get the value of a World Variable like this, from the manual:
var variable = WorldVariableTracker.GetWorldVariable("yourVarName"); var variableValue = variable.CurrentIntValue;
|
|
|
Post by baroquedub on Jan 30, 2017 11:37:43 GMT
Sorry, I think you misunderstood my question... it's not the difficulty variable that I can't do (which yes, I could define as a CGK world var) but the changing of the syncro spawner MaxToSpawn: i.e. aSpawner.WaveSettings.MaxToSpawn -> this is the pseudo code that isn't in the API. Can I access this setting programmatically?
|
|
|
Post by DarkTonic Dev on Jan 30, 2017 19:24:05 GMT
It's not supported, but likely you can do that. However each spawner has X wave settings, not just one as your pseudo-code shows.
On the other hand, if you actually use the World Variable instead of a number for Min To Spawn / Max to Spawn (in the Inspector), then you wouldn't need to code this at all, aside from setting the World Variable value. I would suggest you do that instead.
|
|
|
Post by baroquedub on Feb 1, 2017 0:00:09 GMT
I'm beginning to understand what you mean, I think... I've set up 5 waves in the Level & Waves settings then 5 Waves on each spawner. (The Waves video tutorial does a good job of explaining this part) Then I set the first 4 Waves on each spawner to have a RepeatWave mode set to 'Until World Variable Above", with each one being triggered by an incrementally larger value for the World Variable I'm now using (Difficulty) Weirdly if I make the last wave, the 5th wave, Endless (i.e. the player has reached the maximum difficulty), then all of the previous waves suddenly have all of their variables (i.e. MinToSpawn and MaxToSpawn values, difficulty threshold) duplicated - they all take on the same values as the endless wave. Surely this isn't right? (It's certainly annoying from a user point of view as you have to go back to each wave's settings and reset everything as it was). - the only workaround I can think of is to make the last wave's difficulty setting higher than it will ever reach, making it by default endless. I'm just not sure if the way all waves' settings are changed to match an endless wave is a good idea (or a bug?) So I guess that should all work, but sadly in my case it's bringing up some really odd spawning (a bunch of enemies suddenly appear up in the sky) but that's no doubt to do with my hacky set-up based on that Red Hawk thread integrating Tactical AI. Thankfully I've found that just having a single endless wave works ok thanks to the looping increment provided by RepeatWave>SpawnIncrease. Could you confirm what that is increasing, i.e. the Max or the Min Spawn value or both?
|
|
|
Post by DarkTonic Dev on Feb 1, 2017 0:18:00 GMT
No, that's not what I mean at all. What I'm talking about doing it not typing a number into Min To Spawn / Max To Spawn, but instead changing the blue dropdown to the right of the number from "Self" to "Variable" and selecting your World Variable right there in the Inspector. This means "use the value of World Variable X whenever this field is evaluated". Then, you only need to set the World Variable value to whatever you want it to be, and it will "just work".
Spawn Increase does not increase Min To Spawn or Max To Spawn, instead a random number between the 2 is still generated, and then Spawn Increase is added to it for the final number to spawn for each repetition.
I do not understand what you're saying about the weird wave problem, but I don't think that's the way you want to do it that way anyway. Are you saying the previous waves change at runtime, or just when you're editing things in Unity?
Sorry but I can't advise at all about Tactical AI, I don't even own that one and have no experience with it.
|
|
|
Post by baroquedub on Feb 1, 2017 21:26:48 GMT
Aah! Now I understand. How cool is that?! As you say, it just works Yet again, proves itself to be a very fine asset with layers and layers of options, lots of flexibility and plenty of potential. Keep making those video tutorials, maybe ones that are a little less about showing the main features, but more delving into real world game creation scenarios. Thanks for your patience with my query.
|
|
|
Post by DarkTonic Dev on Feb 1, 2017 21:43:48 GMT
That's a good idea. I will when I have time. Probably before that though, I will spend some time getting multiplayer features working
|
|
|
Post by baroquedub on Feb 1, 2017 22:23:03 GMT
Now you're talking! You've definitely got my money for an upgrade when you get CoreGameKit working nicely with Photon I've already go my eye on the MasterAudio upgrade for when I next do a multiplayer project.
|
|
|
Post by DarkTonic Dev on Feb 1, 2017 23:26:38 GMT
Excellent! We may do a bundle "all DarkTonic networking plugins" package as well for people who would want both Networking ones, that will be a little cheaper than buying both upgrades separately.
|
|