Search Unity

Core GameKit! Pooling / Spawning / Combat

Discussion in 'Assets and Asset Store' started by jerotas, Jan 27, 2013.

  1. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No, there is nothing in the guide. You use them together but nothing is "integrated". So just add EventSounds to the Killable and use the OnDespawned event to do whatever. However that will also fire not only when it dies, but despawns for other reasons as well. If that's not ok, use the Listener as I described above, and add a line or 2 of code.
     
  2. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    kk, ty.

    Some other issues:

    1. Trying to use prefab pool for killable death prefab type and pool.
    I keep getting:

    NullReferenceException: Object reference not set to an instance of an object
    DarkTonic.CoreGameKit.Killable.get_CurrentDeathPrefab () (at Assets/Plugins/DarkTonic/CoreGameKit/Scripts/Combat/Killable.cs:1916)
    DarkTonic.CoreGameKit.Killable.SpawnDeathPrefabs () (at Assets/Plugins/DarkTonic/CoreGameKit/Scripts/Combat/Killable.cs:1086)
    DarkTonic.CoreGameKit.Killable.PerformDeath (System.String scenarioName, Boolean skipDespawn) (at Assets/Plugins/DarkTonic/CoreGameKit/Scripts/Combat/Killable.cs:894)
    DarkTonic.CoreGameKit.Killable.LateUpdate () (at Assets/Plugins/DarkTonic/CoreGameKit/Scripts/Combat/Killable.cs:490)

    even though the prefab pool exists and is also set up in pool boss.
    If I choose Specific and the drop the prefab in directly it's fine.

    2. If have a destroy effect with some 3d fragments as well as particle effects.
    It's an asteroid explosion that blows off 3D chunks (via rigidbody) as well as particle effects.
    This works well until the limit of the prefab pool size is reached, then the chunks don't appear anymore as they have disappeared from the prefab. The effect parent has a particle despawner on it but it seems the child 3D chunks are lost when they are detached on the initial spawn.

    How can I use these properly?

    ty
     
    Last edited: Jul 1, 2016
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    #1, the only time I've seen Prefab Pool code fail is when the items have been actually destroyed by non-CGK code with GameObject.Destroy. If you are positive that hasn't happened, I don't have any ideas. You'll need to send me an example project that reproduces the problem.

    #2, I don't understand. Please explain with longer detail.
     
  4. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    #1 Will recheck

    #2 I have a death prefab which is a composite of particle effects and 3D child objects ( small rocks). When an asteroid expodes, the explosion effect is instantiated and the smaller 3D child objects are animated via rigidbody to simulate rock chunks blowing away.

    When it is despawned via the pool the child particle effects remain but the child 3D objects are gone when it's placef back in the pool.

    It's a commen effect, spawning explosion fragments + particle effects as child objects of a main FX object.

    It's the asteroidExplosion from kalamona's sci-fi spaceship effect pack on the asset store.

    How do I configure it so poolboss instantiates it correctly on respawns?
     
    Last edited: Jul 1, 2016
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    If you have destroyed (GameObject.Destroy) things before they despawn, there is no getting those back. You must remove any destroy scripts so this doesn't happen.

    If you are saying they've just become invisible or whatever, you may need to add a script to the invisible parts to reset their state. Use the OnDespawned method which gets called just before despawning occurs.

    If it's something else, please explain more.
     
  6. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    #1 I'm still getting an error


    NullReferenceException: Object reference not set to an instance of an object
    DarkTonic.CoreGameKit.Killable.get_CurrentDeathPrefab () (at Assets/Plugins/DarkTonic/CoreGameKit/Scripts/Combat/Killable.cs:1916)
    DarkTonic.CoreGameKit.Killable.SpawnDeathPrefabs () (at Assets/Plugins/DarkTonic/CoreGameKit/Scripts/Combat/Killable.cs:1086)
    DarkTonic.CoreGameKit.Killable.PerformDeath (System.String scenarioName, Boolean skipDespawn) (at Assets/Plugins/DarkTonic/CoreGameKit/Scripts/Combat/Killable.cs:894)
    DarkTonic.CoreGameKit.Killable.LateUpdate () (at Assets/Plugins/DarkTonic/CoreGameKit/Scripts/Combat/Killable.cs:490)


    on
    return _deathPrefabWavePool.GetRandomWeightedTransform();

    from
    CurrentDeathPrefab() in Killable

    It says this " This returns a random (unless you've set the Pool to non-random)"

    The Prefab pool exists
    It contains two prefabs both tested successfully as Specific types in Killable

    It returns the same error whether the prefab pool is set to Randomized or Original Pool Order.

    I can't see any other settings as to why this doesn't work.

    The prefab pool is selected in the Killable (otherwise I wouldn't be able to get the error messages! duh!) but when I List or Select in the Prefab Pool nothing shows up.
    --- Found 0 matching Objects(s) for Prefab Pool: (~None~) ---
    UnityEngine.Debug:Log(Object)
    WavePrefabPoolInspector:FindMatchingSpawners(Transform, Boolean) (at Assets/Plugins/Editor/DarkTonic/CoreGameKit/PrefabPool/WavePrefabPoolInspector.cs:68)
    WavePrefabPoolInspector:OnInspectorGUI() (at Assets/Plugins/Editor/DarkTonic/CoreGameKit/PrefabPool/WavePrefabPoolInspector.cs:138)
    UnityEditor.DockArea:OnGUI()

    EDIT: I found the issue

    I was using a Killable subclass based off Killable Subclass. On an intuition I reverted to Killable class and the prefab pool works. It seems prefab pool does NOT work for subclassed killables, which makes it difficult if you need to do some custom event handling no?


    #2
    I guess I need to write a custom script to handle composite FX objects with child objects as PoolBoss doesn't seem to do it.

    Edit: Solved #2 as well.
     
    Last edited: Jul 1, 2016
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I believe we're using Prefab Pools with sub-subclasses of Killable. Perhaps you're not calling the base class in one of them? Can you send me your subclass and sub-subclass?

    #2, what will your script need to do? All pooling plugins have the problem that needs to be worked around that however the object is when it's despawned is how it will be when re-spawned. That's why OnSpawned and OnDespawned code hooks exist.
     
  8. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    I'm just using the sample one included to test:

    // ReSharper disable once CheckNamespace
    using DarkTonic.CoreGameKit;

    // ReSharper disable once CheckNamespace
    public class KillableSubclass : Killable {
    // ReSharper disable once OptionalParameterHierarchyMismatch
    public override void DestroyKillable(string scenarioName, bool skipDeathDelay = false) {
    // ReSharper disable once ConvertToConstant.Local
    var enemyReachedTower = true; // change this to whatever your logic is to determine true or false

    // ReSharper disable once ConditionIsAlwaysTrueOrFalse
    if (enemyReachedTower) {
    scenarioName = "Reached Tower"; // change the scenario name to one of your others, instead of the default.
    }

    base.DestroyKillable(scenarioName, skipDeathDelay);
    }
    }

    Do I need to be implementing more?

    I think I can do what I need with just Killable and Killable Listener actually.

    What's the best way of determining what object collided with another object?
    If I need to check a specific type of object collision?
     
  9. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I tried just now to use KillableSubclass and it worked fine. Note that I got rid of the scenario determining code there since my Killable doesn't have a scenario named "Reached Tower". Otherwise it would log an error in the Console telling me that. So I just kept the base.DestroyKillable. Not sure what logic you have in your subclass. A subclass doesn't have to change *anything*. Your choice what you want to override or not.

    In any case, I was able to spawn the death prefab from a Prefab Pool without any issues. So it's not "subclass" that's the problem, you have something else going on. I have no clue what though. Again, you'd need to send me a slimmed down example project that reproduces the bug or I'm not sure how to provide more help.

    If you want to check what collided, you can override other methods of Killable in the subclass, such as TakeDamage. That method will have the "enemy" passed into it so you can check what it is.
     
  10. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    The scenario with killable subclass works, I added one and tested it.

    All I'm doing is what is in the docs & it's throwing an error. Killable works, subclass killable throws error.

    Can you please provide a simple example using the included core gamekit assets that demonstrates it works with prefab pool spawning?

    if a killable subclass is the only way to detect the type of object collider then I have to get this working.
     
    Last edited: Jul 2, 2016
  11. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I used KillableSubclass with only one line in the overridden method:

    base.DestroyKillable(scenarioName, skipDeathDelay);

    Then I remove Killable from my prefab, added KillableSubclass instead, set up a death prefab in the Inspector (using a prefab pool) and hit play.

    You've done all this? If so, what was the result? What "in the docs" are you referring to that you've done?
     
  12. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    That's exactly what I've done and it throws the error as described previously.
    The subclass is working up to a point as the test scenario gets fired ok, but it's throwing an error on the prefab spawn as evidenced by the error messages above.

    The only thing I can think of is this is an execution order issue with subclass for some reason?

    I can't give you a test project as this is a prototype project with a bunch of other assets.

    I'd rather see an example from you that works and see if that works in my project.
    All the other CGK examples work fine, there must be something different here as to why it works with Killable but not a subclass.
     
  13. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    We don't ask for your actual game project. Typically users create a very stripped down example that shows the bug and send me that. Might be cubes and spheres and no real graphics. I don't think execution order is a factor.

    I could send you a modified example Scene #2 if that's what you want to see? Not sure I'll have any time before July 5th to do so though.
     
  14. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    There's obviously an edge case here that's causing the issue.

    You just tested an example but you can't send it to me?
     
  15. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    After some debugging, the problem with subclass is:


    private Transform CurrentDeathPrefab {
    get {
    switch (deathPrefabSource) {
    case WaveSpecifics.SpawnOrigin.Specific:
    return deathPrefabSpecific;
    case WaveSpecifics.SpawnOrigin.PrefabPool:
    return _deathPrefabWavePool.GetRandomWeightedTransform();
    }

    return null;
    }

    _deathPrefabWavePool is null for my subclass.

    But it is filled in in the Inspector.

    Question is why is this being set ok for Killable but not the subclassed killable?

    Edit:
    I suspect SpawnedOrAwake is not getting called for my subclass, which is why the _deathPrefabWavePool is null

    Solved:
    I'd created a Unity class by inspector which added an empty Start method.
    Then I added the demo subclass killable code.
    The issue was the empty Start() method in the subclass was stopping the base.SpawnedOrAwake from being called, which is used to fill the _deathPrefabWavePool

    Kind of obvious in hindsight but might save someone some time in the future if you could add a little more info in the docs on creating subclass killables and traps to avoid.

    ty
     
    Last edited: Jul 2, 2016
  16. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Here it is, fighter 2 is a subclass, has death prefab of "Mixer Enemies" prefab pool.
     

    Attached Files:

  17. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Add some debug logging to see if it is. If it is and you're still stuck, post the class file for your subclass here.
     
  18. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Already did and solved it, please see http://forum.unity3d.com/threads/50...g-spawning-combat.167910/page-34#post-2703380

    Turns out the edge case was my brain;-/ Perils of programming while tired.

    Ty for the help.
    It's a complex package that takes a little to get your head around but it's starting to click now.
    The documentation helps a lot.

    I think you should update the examples displaying some of the more advanced features using subclasses and listeners, as well as a 3D example.

    It's a great package and I think will make my app a lot more flexible, especially for testing levels and pacing.
    The relationsInspector is also pretty handy, though a view sorted by level first (as opposed to spawner) would be very handy too.

    Thanks again for the support, it makes a big difference.
     
    Last edited: Jul 2, 2016
  19. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    A1, ty.
     
  20. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Ok, I knew this. Ran into it before. The way forward is to not add any MonoBehavior events to your subclasses that Killable already implements.

    You should have done this in your subclass if you needed Start:
    Code (csharp):
    1.  
    2. protected override void SpawnedOrAwake(bool spawned=true)
    3. {
    4.      if (!spawned) {
    5.         // your "start" code
    6.      }
    7.  
    8.      base.SpawnedOrAwake(spawned);
    9. }
    10.  
    11.  
    Perhaps I will revise the examples.
     
  21. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Worth putting in the manual then;)
     
    jerotas likes this.
  22. Robaato

    Robaato

    Joined:
    May 18, 2014
    Posts:
    3
    Hey, loving Core Gamekit so far. I've stumbled across a weird bug. Accidentally hitting the Relations Inspector button will pop up a Relations Inspector window that is very difficult to close and I'm getting this error on every frame while the window is visible in the editor:

    NullReferenceException: Object reference not set to an instance of an object
    RelationsInspector.Workspace`2[UnityEngine.Object,RelationsInspector.Backend.CoreGameKit.PrefabEventType].Update ()
    RelationsInspector.RIInternal.Update ()
    RelationsInspector.RelationsInspectorWindow.Update ()
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    UnityEditor.HostView.Invoke (System.String methodName, System.Object obj)
    UnityEditor.HostView.Invoke (System.String methodName)
    UnityEditor.HostView.SendUpdate ()
    UnityEditor.EditorApplication.Internal_CallUpdateFunctions ()​

    I can close the RI popup window if I mash click right beneath the close window button...

    I'll get hit with a similar error if I click on RelationsInspector in the Window menu while in Play mode.

    I'm quite sure this isn't the way Core Gamekit is supposed to work (haha). and I don't even need this Relations Inspector plugin as I really don't get the point of it. What's the best way of disabling it? I also have Master Audio installed, if that helps.
     
  23. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You can't disable it although you could try deleting the folder and see if that works. The icons to launch it will still be visible but might be smart enough to do nothing when clicked. I wasn't able to get any errors with it though. Which button did you accidentally click and when (during runtime / edit time)? Also, is everything installed in the default folders or have you moved anything?

    As far as what RelationsInspector useful for in CGK:
    1) Shows the relationship of Killables to other Killables that they spawn on various events (damaged / death / deal damage / invincible hit / etc).
    2) Shows what spawners are used in what global waves and what they spawn.
     
  24. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I looked into this over a year and a half ago... Am I still understanding this correctly, that a synchro spawned elimination wave has to have all its objects destroyed before the next wave can start? And if you say 'wave is done when 50% are destroyed', will that then auto-destroy the rest of the wave and then start the next wave, or will it leave the remaining spawned items still active until they're destroyed? Has this changed at all?

    I basically want 'overlapping waves' and it seems the only real way to do that is with triggered waves, right? And then that means I have to a) manually manage the monitoring of whether all spawned objects and waves are 'done' to complete the level, and b) handle the timing of the spawning by triggering certain events at certain times manually from a script? Any other way to efficiently trigger some 'triggered waves' in a sequence over time without resorting to custom code/API calls?

    Is there perhaps a way to force the next wave to start spawning even though the previous wave hasn't fully despawned, like from a timer script or something? Would this break the system somehow? i.e. could I disable the auto wave advancement and manually start the waves so they overlap?
     
    Last edited: Aug 11, 2016
    Dawar likes this.
  25. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    This has not changed. If you have "wave completion %" on the spawner(s) set to 50%, any remaining items that have already spawned will stay.

    So yes, you can do overlapping waves with synchro spawners with that setting.

    With Triggered Spawners, you could use Playmaker to fire "Code-Triggered Event 1" every X seconds, or just use the repeat wave functionality if it's the same spawners over and over.

    You could also try this:
    1) Use timed global waves and don't have any syncro spawners. Instead, use the "wave completion custom events" on each global wave to fire 1 or more Triggered Spawner waves that can have various delays on them if you like.
     
    Last edited: Aug 11, 2016
  26. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    oK thanks. On the global wave thing, as you saying to have some 'empty' waves that are just there for timing purposes and which end at a certain point and signal the triggered spawners to do something?

    Thinking about it the % wave completion won't work because that means the player can be lazy and just not engage the enemy for ages and ages causing the next waves not to spawn. I want things to keep coming, requiring the player to engage in a more intense gameplay and to get more 'work' done. Maybe a timed spawner would be better. I think you said before they can overlap and you can set how much time passes before it spawns.
     
  27. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Btw the reason I'm coming back to using your kit is because I went through and designed my own spawning system and all the features (just a feature list) and then compared what I needed it to do to what your kit does and your kit does 95% of everything I wanted it to do :-D So then I thought, I might as well just save time and use your kit and try to patch up any holes.

    Like, there's one thing I need to do, which is that when the player loses a life, I need to trigger an animation or a despawn where every object temporarily goes away and then returns after a short delay in the same locations as before with the same spawned objects as before. Not sure how I can do that within your kit other than to manage it myself with some kind of triggered animation event on each object.

    Also I need a similar thing where, if the player fails to protect his units enough and they all die, it suddenly triggers every single enemy to morph into a more menacing enemy and they all start to home in ... this means 'converting' all enemies into a different kind of enemy... most of that is animation and state machines and a choice of AI which can run on the prefab itself, and I don't think Core kit can really 'convert' one type of enemy into another.

    My setup at the moment is to use a set of 4 or 5 main levels which will loop around indefinitely, and each time things will get harder. Each of these levels will have a set of waves - some will be identical but others varied, and the 3rd level will be more of a boss level and the 4th level an easier 'rest' level. Then inbetween these levels, I'm adding in a 'summary' level where I can display score/achievements etc following level completion. And then also inbetween the summary and the next level I am having a hidden level for a kind of 'malfunction' level which occasionally activates with a whole different kind of enemy. And also maybe occasionally a 'big boss' level kicks in. This is all inside a nice little level loop. So all I have to figure out really is how to spawn more/harder/more frequent enemies in overlapping waves inside each level. I understand the global values thing and how to use that to increase difficulty. So it's just down to the best way to get the waves to spawn and overlap.

    This really is an excellent tool btw, I think you could easily ask $50 or more for it. Probably even like $75 or $100, it's so feature-rich and well done, it should be recognized of as one of the best tools on the asset store. I realize a lot of 2d (mostly?) developers may not have as much money, I guess you have to figure out whether low cost + more users is better for you than higher cost + fewer users, but really, this is such a good asset, I'm really surprised you are only asking $25 for it right now, given I see 'complete games' and less flexible templates and such asking upwards of $100-$200 and most of what they do is more specific and less capable. I'd put this tool up in the ranks of like 2d toolkit and such, in that 75-100 bracket.
     
  28. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Small question... level settings, added several levels - global waves, is there no way to re-order/sequence the levels, like if I realize that I need another level inserted a couple of levels back... there's no way to go back and insert one there or to move a level I already set up to be run in a different order? Also for waves... looks like you can add but if you want to play them in the right order and change the order after you build it, there is no way to reorder them in the inspector or to insert/move a wave (i see you can clone which is insert, but no move)? Maybe this is a feature request, but it makes things a bit harder to 'get right first time'.

    Also being able to NAME a level would be useful to keep track of what's what even when the levels are collapsed in the inspector. I'd like to show the 'name' of the level in the game. Also can you show the wave name in the inspector when the wave is collapsed? Just going by numbers isn't too easy.
     
    Last edited: Aug 11, 2016
  29. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    That's true if your enemies despawn by themselves (by going offscreen or whatever else triggers despawn). Correct on the 2nd point.
     
  30. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Thanks man. Previously we had this at $50 and barely anyone bought it. I think it does a tremendous amount as you noted, but it's not a "complete game kit" as some of those other packages are. You can't make a certain narrow type of game in an hour for example. Instead we concentrate on being able to make several types of games but not making such narrow features as those products often contain. You may need AI and other various scripts / plugins as well as CGK depending on what sort of game you want to make. I think a lot of people just don't have a good idea of what CGK can do because it's not marketed as anything so specific, and I'm not really sure what to do about it.

    Yes, your death scenario is something you'd need to code, but the right hooks are there for you to use (i.e. you can use a World Variable Listener subclass for the "lives" variable so you can execute code whenever you die. Or it could be a Killable Listener if your player is a visible thing. You can get ahold of all objects spawned by a Syncro Spawner so you can activate an animation..

    #2, if your units all die, you could "convert" them by just writing a loop to despawn each enemy and spawn its evil cousin in the same spot.

    These are easily done with a little bit of script.

    Big boss level, could have "wave skip criteria" of a certain score or something. Or you could set a World Variable to a random value each time wave 1 starts and use that value.
     
  31. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No, that could get a little hairy. It is on the roadmap though, someone asked for that last week.

    It looks like currently you can only name the wave, not the level, right?
     
  32. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Yah you can name the waves. You just can't see the names when things are collapsed. I don't know how people would set up a large number of waves and then find they need to change the sequence order and find they can't move them around.

    Thanks.
     
    jerotas likes this.
  33. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    525
    @jerotas One thing you could do, but of course it would take time and effort, would be to create maybe 5 different example game tutorials that show people how to get started making those different games. If you wanted, you could also have a separate download page where people could download those tutorial examples (i.e. no reason to add it to what you have now). Just a thought. Awesome package!
     
  34. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    It's a good idea. I just don't have the time anymore for stuff like that. Thanks!
     
  35. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    What is the 'prefab pool group' for.. I'm not sure I saw anything in the documentation. I now the pool is for like weighting which enemies will spawn... But this other script, is it a group of pools? How is it used?
     
  36. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Regarding marketing, if you don't have time, maybe you can form a partnership with someone else who has other related assets, e.g. Game art/animation assets... Use their assets to make a small game or have someone do it, and then include that. You can then bump up the price and allow the assets to be used and share the profits.
     
  37. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    It's just a script used for Prefab Pools. There's no hidden feature :)
     
  38. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Noted, thanks!
     
  39. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I looked on your forum but couldn't find anything really about how to do basic player bullets. Maybe its in this thread somewhere but its a lot to wade through and google was no help. I can program a bullet launcher/handler/animator myself but I want to set it up to be managed by the kit.

    I'm getting the impression I need to set up some kind of wave, maybe a triggered wave? And it needs to be added to every level manually? And then this wave would have to somehow last the whole level, how? Or is a wave not needed at all? Then do you like, set up a trigger spawner somehow in a script or something? Then trigger it to spawn 1 shot when the player presses a key from a script? And the bullet object is a sprite with a killable script on it and should despawn when invisible/offscreen and should have some attack points? And then... how do you get the bullet to aim in the direction the ship is pointing (left or right)? And how might I add extra speed to the bullet (player ship's movement speed + default bullet speed)?

    Am I barking up the wrong tree? ............ seems I need to use some custom events or something like that to trigger the shots to spawn?
     
    Last edited: Aug 12, 2016
  40. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You could use Custom Events, or you could just code it in your player script to spawn a bullet with Pool Boss. Not much different there. If you want a "3 spread shot" like the enemies in level 2, then it makes sense to set up a triggered spawner wave. Otherwise for single stuff, not really.

    Yes a bullet would normally be a Kllable with despawn offscreen and attack points, layer filter etc.
     
  41. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I'm having a bit of trouble. I implemented code to do 'auto fire' to shoot bullets upon a keypress. It works. I use SpawnOutsidePool to spawn bullets (of which there are up to 200 instantiated) from PoolBoss. This works. The bullets each have a script on them that moves the bullet. The script also detects if the bullet moves too far and then calls Despawn() to despawn it. This works.

    The trouble is, as bullets despawn, over time they start to spawn much less often. It seems like the ones that were despawned off-screen often are re-spawning off-screen instead of at the location I'm telling them to. It's as if they're not running their Start() function to initialize their position a second time? After a while there are almost zero shots coming out because they're all off-screen and so seem to depawn right away.

    Ever seen this happening? It could be my bug I guess but I don't understand it. Even if I remove my line to despawn bullets, and if I add a 'timed despawner' script on the bullet prefab of 1 second, they do despawn, but then each time something 're-spawns' it spawns off-screen as if carrying on where it left off.

    What am I missing? Is there some reason the object isn't properly reset or something after a despawn? Or its start function doesnt run? When I added a debug log to the start function of the bullet, it only runs when the bullet successfully spawns, and for all the rest of the bullets it does not get called. I see the bullet seem to spawn 'at' the player but then it immediately despawns.
     
    Last edited: Aug 14, 2016
  42. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    First, you have written code you didn't need to. There's a "death distance" field in Killable you can enable for that first part.

    As far as Start code not running, that is correct. If you read the PoolBoss section carefully it mentions that Awake and Start functions are never called again after the first spawn (which makes sense since the objects are not being destroyed, just set back to disabled).

    However, on the first and every other respawn, the OnSpawned method is called by PoolBoss. Normally I move all code from Start into OnSpawned for anything that is pooled.
     
  43. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Ok the OnDespawn works... I was going to shift stuff into an 'initialize' function that I was going to call after spawning, but this is better.

    The death distance I can't use. My game world wraps around. It makes the math for comparing positions much more complicated especially given my bullets move faster based on the player moving faster and so distance covered varies. Also I couldn't despawn when invisible/off-camera because I have 7 cameras and the whole game world is always visible on the scanner.

    Everything is working correctly now, thanks. .. ... mostly placeholder graphics at the moment but it's looking cool now that the triple-fire + auto-fire + shot spawning/despawning is working :)

    Screen Shot 2016-08-14 at 2.53.02 PM.jpg
     
    Last edited: Aug 14, 2016
    jerotas likes this.
  44. Almakos

    Almakos

    Joined:
    Dec 13, 2013
    Posts:
    179
    Hey jerotas,
    I have a question about one core game kit feature.

    In my game there are some asteroids which I am destroying with bullets.
    I want bigger asteroids shatter into smaller ones

    In Death Prefab Settings & Events (in killable script) I have set to spawn 5 smaller asteroids when 1 big one is destroyed
    Also I've set Inherit Velocity and Rotation Mode set to Inherit Existing Rotation
    Everything works but looks rather repetitive
    Any way to set randomised offsets and rotation?
    Or is there anything else you'd recommend?

    Thank you
     
  45. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    It looks like I've forgotten to add the random rotation checkboxes for the Death Prefab. Other Killable-spawned prefabs have it. I'll add that for the next version.

    In lieu of that, you can add a script to your smaller asteroid that uses the OnSpawned method and set a random rotation there. Also could move Vector3.Forward a random amount if you like or apply random forward force.
     
  46. Almakos

    Almakos

    Joined:
    Dec 13, 2013
    Posts:
    179
    I see, thank you for clarification.
    Thing is that I already have smaller asteroids being spawned (so that there are asteroids of various sizes and shapes fly towards the player)
    So if I set their rotation to random on spawn they will just fly in different directions and not the direction intended
    However after bigger asteroids are shattered it's ok to fly in different directions =)

    It's fine I'll wait for the update and hope that it will fix this for me :p
     
  47. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
  48. 76bigfoot

    76bigfoot

    Joined:
    Oct 14, 2015
    Posts:
    7
    Hello jerotas,
    I created an empty project with Unity 5.1.1f, and then imported the Core GameKit and Master Audio plugins. Now I'm getting an error.

    Assets/Plugins/Editor/RelationsInspector/BackendUtils/MinimalBackend.cs(11,54): error CS0433: The imported type `RelationsInspector.IGraphBackend`2' is defined multiple times

    Any suggestions to fix this.

    Thanks for the support.
     
  49. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Hey, I just made a new project and imported both. No errors.

    I can only suggest you delete the entire Assets/Plugins/DarkTonic and Assets/Plugins/RelationsInspector folders and re-import both plugins again after restarting Unity. Hopefully that will fix you.
     
  50. 76bigfoot

    76bigfoot

    Joined:
    Oct 14, 2015
    Posts:
    7
    Hello jerotas,

    Nope, it didn't resolve the issue. I tried on a different PC. upload_2016-9-16_17-32-17.png

    I'll try to do some more digging to see where the 'RelationsInpector.IGraphBackend' is defined.

    Thanks.