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
    Did you delete the DarkTonic folder too? You need to. You may also need to close Unity and re-open it before installing the plugins again. And then delete UndohHelper1. As I said, the next update will not have the UndoHelper problem. I've changed the file name for Master Audio.
     
  2. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    I did removed DarkTonic folder too. The whole lot - I removed every files and folders that Master Audio had installed.
    The only thing I didn't do was to close Unity and reopen it again before installing. I will try that now.
     
  3. closetgeekshow

    closetgeekshow

    Joined:
    Jun 6, 2014
    Posts:
    125
    Just updated Core GameKit to 3.2.3.8 and noticed a minor error in KW_Instructions7.cs, the class name is incorrent.
     
  4. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    There is no KW_Instructions.cs file. Maybe it's old? Please delete it.
     
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I've made all the values for Core GameKit fields draggable like normal Unity fields now. You know, like when you drag the X for a Vector3 left or right and it changes the value?

    Now you can drag the I or F (for Int or Float value) next to the value left or right and the value will change accordingly. This used with the new visualization feature should make setting up waves a snap and very very quickly done!

    This will be in the next update.
     
  6. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574

    Yep, I deleted ALL reference to Darktonic/Master Audio/Core Gamekit, restart Unity, install Master Audio, Install Core Gamekit, and it still gives me the same warning/errors:

    Warnings:
    Created unique file for imported asset as file exists with different GUID (Assets/DarkTonic/Editor/UndoHelper.cs => Assets/DarkTonic/Editor/UndoHelper 1.cs)

    Model 'KillerWaveSpawnWidget' contains animation clip 'Default Take' which has length of 0 frames (start=-1, end=-1). It will result in empty animation.

    Error:
    Assets/DarkTonic/Editor/UndoHelper.cs(11,21): error CS0101: The namespace `global::' already contains a definition for `UndoHelper'

    The thing is, I noticed the UndoHelper is of different dates - one on 15th one on 20th, and they seem to be formated slightly differently. Maybe Unity 5's new behavior is not to overwrite file of same name when it is from different Asset?? (Or if Unity detected the files are actually different hence different GUID thus Unity refuse to overwrite it? - I think solution would be to use exactly same file for both asset so they are same GUID?) Anyway, I just deleted the older version (Undohelper.cs) and rename the UndoHelper 1.cs to UndoHelper.cs and everything seems to be fine again. Its no big deal, just a little bit annoying that's all. :)
     
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    They probably are formatted a bit different. That doesn't matter. Yes I believe Unity 5 behavior is to "keep both". Anyway, I have renamed the Master Audio one to AudioUndoHelper.cs so when the next MA update comes out, this program will no longer exist. Sorry about this.
     
  8. The_Least

    The_Least

    Joined:
    Jan 21, 2015
    Posts:
    27
    Is there an easy way to kill Killables when their parent is killed? I have an enemy with multiple child Killables on various body parts. The player can target-fire the children Killables (they have fewer hitpoints), but it's easier to just blow the limb away (more hitpoints, but larger targets). When the parent limb is killed, I want the children to be replaced by their death prefabs (which have rigidbodies on them, so debris flies everywhere).

    Can this be done simply, or will I have to write a custom script for this?
     
  9. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    There's no automatic way. You can do the opposite with no code, where the limbs take no damage until all child Killables are destroyed.

    It would be pretty simple to write a subclass of KillableListener to do this. I haven't tested it, but the following should work, if you use this listener for the limb Killable.

    Code (csharp):
    1.  
    2. public class KillableListenerLimb : KillableListener {
    3.   public override void DestroyingKillable(Killable deadKillable) {
    4.       for (var i = 0; i < deadKillable.Trans.childCount; i++) {
    5.          var childKillable = deadKillable.Trans.GetChild(i).GetComponent<Killable>();
    6.          if (childKillable == null) {
    7.             continue; // in case this child doesn't have a Killable component, skip it.
    8.          }
    9.          childKillable.DestroyKillable();
    10.       }
    11.    }
    12. }
    13.  
    It's possible that the loop counter might do *every other* killable if the children are destroyed during the loop. If so, the code would need to be modified to destroy the children at the end.

    Since it's so simple, I'll add this to the roadmap to do automatically.
     
  10. The_Least

    The_Least

    Joined:
    Jan 21, 2015
    Posts:
    27
    Thanks. it does work as intended (only kills children Killables) - however it only affects direct children, not children of children. I probably should have mentioned that I have multiple Killables grouped under nulls for animation's sake :)

    EDIT: For my own purposes, I think I'll just edit this script to use an array of public variables so I can assign the child Killables in the Inspector. Thanks again.
     
    Last edited: Mar 25, 2015
  11. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No problem. I'll be adding a "destroy when parent Killable dies" checkbox so it's more flexible and will work like your modified script.
     
    The_Least likes this.
  12. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Hi Brian

    Just checking the documentation for LevelSettingsListener which shows the EliminationWaveCompleted method is available, but when I check the source code, its missing?

    Is it possible to add this please?

    cheers,

    Nalin
     
  13. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I don't think it's needed. You can use WaveEnded if it's elimination or not, unless you need it for "wave is about to repeat"?

    If not, I'll remove that part from readme.
     
  14. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Actually I think I need it for "wave is about to repeat" because I wanted to listen for the event when a wave is about to repeat, so I was hoping to use that event along with sequencedWaveNumber to be able to display something like

    levelWaveInfo.waveName + levelWaveInfo.sequencedWaveNumber;

    However WaveEnded() does not get called when the wave repeats, and neither does WaveRestarted() or WaveStarted().

    Any suggestions here?

    Also, is it possible to get hold of the total number of repetitions at all?

    cheers

    Nalin

    BTW You might want to mention in the manual that to make the listener work, subclass from LevelSettingsListener, and then attach that script to an empty GameObject. Then drag this into the Listener slot in LevelWaveSettings.
     
  15. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    It was a typo in the readme. I've now fixed the readme.

    For clarification, Global Waves do not repeat, only spawner waves repeat. The EliminationWaveCompleted method is in the WaveSyncroSpawnerListener. So each spawner that uses the globally set elimination wave would need to have its own Listener and they could all fire the event at different times, since their waves are all independent from each other.

    But actually that has nothing to do with what you want to display (global wave number will not change during any of this). Yes, we can get ahold of the number of repetitions in that spawner's wave if it's useful to you. Just let me know.

    The readme already has instructions for setting up Listeners, I just checked. You don't need to put Listeners on an empty game object. In fact I usually put them right onto the same object they're listening to, because they "auto-connect" to the Listener field that way. The readme mentions this as well.
     
  16. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Core GameKit will be 80% off for 24 hours tomorrow! That's only $10! This is a great time to get a great tool :)
     
  17. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Ok thanks for the clarification :)

    I have it working now and attached the WavexxxListener right on to the spawner. However I want to display the repeat number of the current wave and I don't seem to be able to find it in WaveSpecifics.cs?

    Also, the number of repetitions in that spawner's wave would be useful.

    The purpose here is so I can display Wave 'w' + CurrentRepetition 'c' + TotalRepetitions 't' as a string.

    Also, I was wondering if it possible to get to the wave level info from WaveSpecifics? as I would also like to be able to display the Wave Name as a prefix to the above string.

    Please let me know if/how this is possible :)

    cheers

    Nalin
     
  18. MattyWS

    MattyWS

    Joined:
    Jan 24, 2013
    Posts:
    70
    I'm curious about this, it shows that it's on offer but insteado f having the daily deal banner in the corner of the image on the asset store it has Level 11.. will there be some kind of Level 11 deal next month?
     
  19. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Not that I know of. We haven't been contacted about that.
     
  20. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    When you're logged into the Asset Store as a Pro user, the website shows the "Level 11" graphic instead of "24 Hour Deals" on the daily 24-hour deal. If you log out, you'll see that it returns to the "24 Hour Deals" graphic. Someone already reported it as a bug.
     
    jerotas likes this.
  21. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You grab current wave # from:

    Code (csharp):
    1.  
    2. LevelSettings.CurrentLevelWave
    3.  
    It's zero-based, so add 1 to it.

    And then the repetitions is in repetitionsToDo. Code like this grabs both.
    Code (csharp):
    1.  
    2. public virtual void EliminationWaveCompleted(WaveSpecifics spec) {
    3.     var wavenumber = LevelSettings.CurrentLevelWave + 1;
    4.     var repetitionsOfWave = spec.repetitionsToDo;
    5. }
    6.  
     
  22. MattyWS

    MattyWS

    Joined:
    Jan 24, 2013
    Posts:
    70
    Ahh I see, first time I've noticed! Thanks.
     
  23. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Thanks Brian :)

    BTW I had to use spec.repetitionsToDo.selfValue because if I leave as is it returns the string 'KillerInt' - this also happens if I use the method .ToString()
     
  24. MrTiger

    MrTiger

    Joined:
    Jan 9, 2014
    Posts:
    29
    Hay thx for your plug in it look really good .i m making a game and its almost finished .in my game i need only the pooling system from your core game kit other things i have already done like score ,exp points , health ,etc... so now i want to know what are the unwanted script i need to remove other then script needed for pooling system or is it a good idea to buy your pool boss plugin ? (i am fine with that ) and also few simple example scripts. but b4 that let me explain what my game want . enemy spawn should be controlled by my script like when they have to spawn and where and what enemy . so this are the things i need to know .
    1)how do i pool object from your pooling system using custom script .
    2)after pooling how do in deactivate it to pool it again using custom script .

    if you can . make a script like when i press a button or mouse it should spawn a object then after few sec spawned object will be deactivated . i know it can be done by your spawn script but i want to use custom script coz i already have my script that can call a function now i just want to replace it with another function so my work can be done simple
     
  25. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You should use ".Value" instead of .selfValue. It's a property. The other is a member variable that's only public so the Inspectors can use them.
     
  26. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You can't include less files to use Pool Boss only. But the parts of CGK you don't use won't take up any performance, they lie dormant.

    You can email me with your invoice and I'll send you a link to download the standalone Pool Boss

    1)how do i pool object from your pooling system using custom script .

    I assume you're asking "how do I spawn"? If so, it's PoolBoss.SpawnInPool and commands like that. Take a look at the API website for others.

    2)after pooling how do in deactivate it to pool it again using custom script .

    PoolBoss.Despawn

    For that script, you can modify the included "ClickToDamage" script to use the command above. Also place a TimedDespawner component on the thing you're spawning to make it despawn after X seconds.
     
  27. MrTiger

    MrTiger

    Joined:
    Jan 9, 2014
    Posts:
    29
    Hay thx for the quick reply . i just bought the pool boss so no problem . ya i mean "how do i spawn ?". thx again i will check the API web site now if it work for me i will command and give you 5 star in asset store if not i will come back here to clear my doubt ..
     
    jerotas likes this.
  28. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Hi,

    I get this error in Unity 5

    "The name `PlayerPrefs' does not exist in the current context"

    Is there a procedure to make it work in Unity 5 ?

    Thanks
     
  29. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No there is not, it "just works" for me downloading the latest in an empty project. Did you move folders around after importing?

    Core GameKit Unity 5 compatibility was done *months* ago. I suggest you delete the Assets/DarkTonic/Core GameKit folder and re-import.
     
  30. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Thanks, i will try again

    I did not change any folders though, just imported the latest within Unity 5 and got the error directly

    I will try a clean project and see if it is ok there
     
    jerotas likes this.
  31. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Hi Brian

    I just wondered what is the best way of making LevelSettings to restart the entire set of waves if I am creating a single scene game?

    I looked through the code and could find no global restart method. Instead the Awake() code seems to have all the initialisation code in there but I could do with some confirmation as to the best way to do this as I could not find any mention in the manual/readme.

    cheers

    Nalin
     
  32. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Now that Unity 5 gives all pro features for free (well almost all), we will be putting all Core GameKit classes into a namespace (DarkTonic.CoreGameKit) in the next update. This will mean ending support for Unity 3.

    Sorry for the long wait, I know people have wanted this for awhile.
     
  33. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    There isn't a supported way to do it aside from reloading the Scene (so Awake will fire again normally). If you'd like a way, we can put it on the feature roadmap?
     
  34. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Yes please Brian, that would be great :)

    Essentially I am looking to build a game with a single scene so as to avoid loading times etc.

    In the meantime if I call the code in Awake() manually do you know if it will do a proper reset?

    cheers

    Nalin
     
  35. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I do not know. You can try it. I will say it's definitely not meant to be called manually. I'll add it to the roadmap now.
     
  36. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574




    I spotted this in the latest PlayMaker release note: https://hutonggames.fogbugz.com/?W311

    "Unity 5 changes the way assets are imported from a unitypackage. It now uses GUIDs. This can cause duplicate files if you have the same file in your project with a different GUID (e.g., you copied the file in Finder or Windows Explorer and Unity assigned it a new GUID). Please see the Troubleshooting link below to fix this."


    Duplicate files after updating in Unity 5

    "Unity 5 changed the way assets are imported from unitypackages. Instead of overwriting files, if internal asset GUIDs don't match, Unity creates a duplicate file, appending " 1" to the name. Older projects might have Playmaker files with different GUIDs (e.g., files copy/pasted in Finder/Explorer or downloaded from the forums), resulting in duplicate files when importing an update. These duplicate files generally cause errors and need to be removed!"

    https://hutonggames.fogbugz.com/default.asp?W624


    I think this is what's causing problem before - that UndoHelper 1.cs.





    .
     
  37. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You are correct, bawss. As I said, I've changed the name of UndoHelper in our other plugin Master Audio. So when the new version gets approved, this should no longer be a problem.

    Anyway, there's nothing more I can do to fix it.
     
  38. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    I know, I understand that by renaming it solves the problem. Its just that I thought this namespace problem that was plaguing Unity 3 was finally solved in Unity 4. Now its back in another form to haunt us! I think we need to tell Unity to drop that GUID thing.
     
  39. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Hi Brian

    In a method like this in the WaveListener, I am wondering how to get the wave name from WaveSpecifics:

    public override void WaveRepeat(WaveSpecifics spec) {
    }

    I have had a trawl through the code and it's not obvious to me so I was hoping you could point me in the right direction please?


    cheers

    Nalin

    BTW Another feature request I would like is a "Duplicate" button 1) in each wave Spawner (so that the settings can be preserved/modified) and 2) for Waves in the LevelSettings as well.
     
    Last edited: Mar 31, 2015
  40. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I agree!
     
  41. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    WaveSpecifics is the spawner's wave, so there is no wave name. Only the Global waves have names, so you can't grab it from "spec". You can grab it here though:

    Code (csharp):
    1.  
    2. LevelSettings.CurrentWaveInfo.waveName;
    3.  
    I'll put the other requests on the roadmap, those are good ideas.
     
  42. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    hmmm, if I use this with a repeating wave, then on the second repetition the wave name seems to change to that of wave 2 when I was expecting the wave 1 name to remain?

    Thanks re the other requests :)

    N
     
  43. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yeah that's correct. And there's not really a way to fix that unfortunately. The global wave engine goes forward after the Spawners are notified to spawn the wave.
     
  44. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    hmmm

    This might also explain that when I try and print out LevelSettings.CurrentLevelWave in the same place, after the first wave (with a couple of repetitions) when I try to print it subsequently it has increased by one already - I am doing this in

    public override void WaveRepeat(WaveSpecifics spec) {
    DisplayWave(spec);
    }

    ...thought I was going mad
     
  45. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You saw correctly about this. Although I can't speak to whether you are going mad :)

    The properties like Wave name are really only meant to be shown right when the wave switches (Level Settings Listener events).
     
  46. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Thanks for confirming I am not going mad :eek:

    BTW In case it helps anyone, I have just started using DoTween scripting on prefab objects and I found that when I set a looped tween going in OnSpawned() it would not advance beyond Wave 1 (which spawned such prefabs) unless I put a transform.DOKill(); into the OnDespawned() method.

    No idea why, but I also posted here...
    http://forum.unity3d.com/threads/dotween-hotween-v2-a-unity-tween-engine.260692/page-23

    N

    BTW it would be nice in future if there was a place where all the info for levels/waves could be made available so that it could be displayed. At present it does feel a bit clunky and confusing, plus I am not sure exactly what the way forward is here. When I try to code around the LevelSettings.CurrentLevelWave issue, sometimes it comes through as the right value, whereas other times it comes through as +1 of what it should be - it seems to change randomly with each wave :(
     
    Last edited: Mar 31, 2015
  47. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    The tween thing is probably because when something is despawned (game object becomes inactive), all CoRoutines on it are stopped. Or something from that fallout of that (We don't have any CoRoutines running but I think Hotween does).

    All those properties of waves you are talking about should really only be read when *Global waves* advance. Then they are reliable (although they are zero-based, so always add one). I recall that you are reading things from spawner wave events.

    So I believe you should be using a LevelSettingsListener instead of a SyncroSpawnerListener, then everything should work fine.

    Let me know if you have any further trouble.
     
  48. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Unity 3.2.4 has been submitted to the Asset Store. Changelog:

    • Breaking change (if you have written code): All classes are now in the DarkTonic.CoreGameKit namespace. You will need to add "using DarkTonic.CoreGameKit;" at the top of all scripts you've written that use the Core GameKit API.
    • Updated NGUI package to add the namespaces.
    • Updated Playmaker package to add the namespaces.
    • Updated Behavior Designer packages to add the namespaces.
    • Fixed bug: Knockback damage didn't check receivers for IsGravity on the rigidbody before sending.
    • Fixed compile bug on Web Player.
    • Fixed rare bug with Pool Boss not finding prefab of previously despawned prefab.
    • Now the value of all Inspector fields set to "self" can be dragged like normal Unity fields. Just drag left or right on the I or F (for Int and Float) next to the value. Awesome for the new wave visualization feature!
    • Now Knockback settings work on Rigidbody2D as well.
    • Ignore Offscreen Hits now defaults to false. Since more people are probably using sprites, that old default is going to interfere more than help.
    • Added property "KilledBy" to Killable, which returns a reference to the other Killable that dealt lethal damage to it, if any. Resets itself to Null each time it respawns.
    • Added "If Parent Destroyed?" section below "If Spawner Destroyed" in Killable Despawn & Death Triggered. You can select: Die, Despawn, or Do Nothing (default). This will allow you to make giant ships or fortresses that destroy their limbs when the whole is destroyed or other cool effects!
     
  49. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Hi Brian

    To reset the game within the same scene I tried manually calling Awake() but this failed with lots of errors.

    So I tried to roll my own method because I want my game to have a fast restart.

    As I am just using Syncro spawners with repetitions, so at the end of the game I call PauseWave() to freeze everything.

    Then to restart the game I added a static method to LevelSettings as follows:

    Code (CSharp):
    1.     public static void ResetGameLevelWave()
    2.     {
    3.         EndWave();
    4.         SpawnedItemsRemaining.Clear();          
    5.         PoolBoss.DespawnAllPrefabs();
    6.  
    7.         _currentLevel = 0;
    8.         _currentLevelWave = 0;
    9.  
    10.         UnpauseWave();
    11.  
    12.     }
    This very nearly works but I have two side effects:

    1 - if restarted in the middle of a wave, on restart I get additional objects in the first wave i.e. 6 objects instead of 5
    2 - sometimes the LevelSettingsListener and WaveSyncroSpawnerListener fire at the wrong time

    If you have any ideas or suggestions as to how I might be able to fix these issues, or any recommendations this would be much appreciated :)

    cheers

    Nalin
     
  50. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You could set the Listener to NULL, then run your method above, then put the old removed Listener back.

    For the other problem, maybe just try the LevelSettings.GotoWave method - back to 0-0, (which will probably eliminate the need for you to set the Level and LevelWave in your code as well.