Search Unity

Core GameKit! Pooling / Spawning / Combat

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

  1. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    725
    It seems scene 3 needs to be first in the build settings for the samples to work. The one called "3.Sample Menu" then the demo scenes work. I put them in the order that they were numbered.
     
  2. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    If you want to be able to click the "scene 1" buttons etc, then yes. You don't have to click those though. Individually all the scenes work. No need to modify the build settings because they don't really have anything to do with each other. I had just put those scene switching buttons there for testing some complex code.
     
  3. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    725
    Is there built in code to limit Left/Right Player movement? And is there a toggle or switch to allow forward and Backward movement?
     
  4. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No, on both counts. This is not a full working game by any means. It's to show how the spawners, world variables, Killables and pooling work. Enemy AI, pathing and player movement are not features this plugin deals in. I included little bits of those but they're just for demo purposes.
     
  5. sirius_002

    sirius_002

    Joined:
    Aug 16, 2012
    Posts:
    65
    Hi, quick question; right now my health world variable goes beyond 100, how do I stop this? Thanks!
     
  6. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I can add a maximum value field to the next version. Other than, you would need to use a custom World Variable Listener class and override either the UpdateIntValue or UpdateFloatValue method, depending on variable type. You could add logic there to not let the value exceed whatever number you want.
     
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I have hit a roadblock. I'm trying to just have the default WorldVariableListener display using an existing GUIText component so you can set the font, size, x, y and all that there. However, I can't seem to get a GUIText to display at all. Could someone let me know what to set to what for example scene 1 so a GUIText shows up saying "hello"?
     
  8. sirius_002

    sirius_002

    Joined:
    Aug 16, 2012
    Posts:
    65
    That's cool, I'm kind of working with playmaker, so I will wait for your script instead of writing my own. Thanks for offering to do this, maybe it will be useful for other users as well.
     
  9. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Core GameKit V3.1.9 will be live in about 10 minutes. Changelog:

    • Fixed player projectile. After pooling, gravity was moving them out of 2d collision space on the Y axis.
    • Added Playmaker Custom Actions to get the value of a World Variable. 2 because 2 types (int and float).
    • Added optional max value setting for World Variables. This way you can prevent Health from going over 100 for instance.
     
  10. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    And it will be live in 10 minutes!
     
  11. Chibwemwn

    Chibwemwn

    Joined:
    Feb 6, 2013
    Posts:
    129
    Cool, I'll check this out later, this should help with the whole GUI Issue I've been having :). I'll let you know how this goes.
     
  12. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Ok sounds good. Did you see my other post on the previous page about GUIText? I was asking you specifically.
     
  13. Chibwemwn

    Chibwemwn

    Joined:
    Feb 6, 2013
    Posts:
    129
    If you mean the built in GUI Text, then make sure that it's game object is between 0 and 1. The write "hello" in the required field the inspector offers. Is that what you're looking for?
     
  14. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yeah. However I already tried that and nothing showed up. I was scratching my head after trying about 50 things. Nothing ever showed up.
     
  15. Chibwemwn

    Chibwemwn

    Joined:
    Feb 6, 2013
    Posts:
    129
    Okay so if you're trying to get something from CGK to show up using GUI Text, I'm as confused as you are. But if you just want to use GUI Text on its own, then I don't know what the issue could be. Hmm. I'm guessing you're trying to use GUI Text with CGK?
     
  16. sirius_002

    sirius_002

    Joined:
    Aug 16, 2012
    Posts:
    65
    Seriously you are the best, health now goes to 100 max and I was able to to add hud text through playmaker with the new world variable fsm hookup. Thanks!
     
  17. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No, I just want to get it to show up on the example scene with "hello". If I could do that (I haven't been able to), I can make Core GameKit use it.
     
  18. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Awesome, glad it works for you!
     
  19. Chibwemwn

    Chibwemwn

    Joined:
    Feb 6, 2013
    Posts:
    129
    Hmm, I don't quite understand. I've made it show up on screen... Show me screen shots of how you're setting it up. Maybe that'll help clear things up.
     
  20. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    If you could just show me how to set up a GUI Text saying "hello" on the Example scene 1 (Syncro Spawners), send me a screen shot, using the default Arial font, I'll see if it works for me.

    Thanks!
     
  21. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
  22. Chibwemwn

    Chibwemwn

    Joined:
    Feb 6, 2013
    Posts:
    129
    I hope this helps!
     

    Attached Files:

  23. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Core GameKit v3.1.9.1. will be live in 5 minutes. Changelog:

    • Fixed windows 8 compile errors.
     
  24. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I did exactly the same on Unity 3.5.7. I did note that there is no Color field in 3.5.7. No rich text field either. Other than that, my settings are identical. Nothing shows. Maybe GUIText is screwed up on Unity 3?
     
  25. Chibwemwn

    Chibwemwn

    Joined:
    Feb 6, 2013
    Posts:
    129
    Sorry for the double post! They didn't show up when I first posted them. Anyway, I don't know what to say, but I'm just using Unity 4.3 and GUI Text. On the other hand, I've managed to make a basic Score Counter using the get/set world variable int actions! Those are pretty useful.
     
  26. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Cool. I may try again on Unity 4 soon. I give up on Unity 3 GuiText.
     
  27. Chibwemwn

    Chibwemwn

    Joined:
    Feb 6, 2013
    Posts:
    129
    Hahahah, I've been there! Sleep helps, a lot! So far rigging my own UI system with the playmaker actions has been awesome though. Great work, so far, man! :D
     
  28. rcart

    rcart

    Joined:
    Feb 13, 2014
    Posts:
    5
    Hello, it's me again.

    I want to reiterate once more my appreciation for the new update. The new get variable stuff works a charm.

    I'm discovering, however, that I am in need of a set variable action that executes every frame. Towards that end I have attempted to modify the "CoreGameKitVariableFloatSet.cs" script as follows, and I was wondering if you could look over it to point out if I'm breaking something that I'm unaware of:

    Code (csharp):
    1. public class CoreGameKitVariableFloatSet : FsmStateAction {
    2.     [RequiredField]
    3.     [Tooltip("World Variable Name")]
    4.     public FsmString worldVariableName = new FsmString(string.Empty);
    5.    
    6.     [Tooltip("Repeat every frame while the state is active.")]
    7.     public bool everyFrame;
    8.    
    9.     [RequiredField]
    10.     [Tooltip("The new value of the World Variable.")]
    11.     public FsmFloat newValue = new FsmFloat(0f);
    12.    
    13.     public override void OnEnter() {
    14.  
    15.         DoVariableThing();
    16.        
    17.         if (!everyFrame)
    18.         {
    19.             Finish();
    20.         }
    21.     }
    22.    
    23.     public override void OnUpdate()
    24.     {
    25.         DoVariableThing();
    26.     }
    27.    
    28.     private void DoVariableThing() {
    29.         var trans = this.Owner.transform;
    30.         var modifier = new WorldVariableModifier(worldVariableName.Value, WorldVariableTracker.VariableType._float);
    31.         modifier._modValueFloatAmt.curModMode = KillerVariable.ModMode.Set;
    32.         modifier._modValueFloatAmt.Value = newValue.Value;
    33.        
    34.         WorldVariableTracker.ModifyPlayerStat(modifier, trans);
    35.     }
    36.    
    37.     public override void Reset() {
    38.         worldVariableName = new FsmString(string.Empty);
    39.         newValue = new FsmFloat(0f);
    40.         everyFrame = false;
    41.     }
    42. }
    Obviously all I did here was just move the main code off into a private function DoVariableThing so I could reuse it for OnUpdate (this is the sad extent of my programming ability; I don't even know if I'm describing that correctly).

    It seems to work fine as far as I can tell, but I admit that I do not understand anything from lines 29 to 34 at all, and so can't tell if I'm somehow breaking it inadvertently. Am I doing it wrong?

    Cheers
     
  29. supericon

    supericon

    Joined:
    Feb 15, 2013
    Posts:
    63
    Hi Jerotas

    Any further update on adding this in?

    EDIT: Actually looks like it was added in Core GameKit V3.1.7?
     
    Last edited: Feb 19, 2014
  30. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Correct, v3.1.7 has it :)
     
  31. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    It looks like it will work at a glance. I'll add this in the next version and make sure it works correctly :)
     
  32. rcart

    rcart

    Joined:
    Feb 13, 2014
    Posts:
    5
    Oh sweet! That is greatly appreciated :D.
     
  33. supericon

    supericon

    Joined:
    Feb 15, 2013
    Posts:
    63
    OK - so I have just done some tests - it restarts the wave, but all the enemies already spawned are untouched, so you get the wave restart enemies plus those already active, making it really nasty if you die.

    Is there any way to desapwn all the current wave's active enemies?
     
  34. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Just despawn, or destroy? There's a difference. Destroy (assuming they have a Killable script) will spawn their death prefab (explosion etc). I think it's kinda weird if they just disappear.

    Anyway, that functionality doesn't exist, but I can add it. Which one?
     
  35. supericon

    supericon

    Joined:
    Feb 15, 2013
    Posts:
    63
    I don't use killables as the enemy health is controlled by a separate component (we're working with UFPS camera which handles damage).

    So for what we need, despawn ideally.
     
  36. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I think I'll add the option for either.
     
  37. Chibwemwn

    Chibwemwn

    Joined:
    Feb 6, 2013
    Posts:
    129
    What does this error mean?

    Cannot change GameObject hierarchy while activating or deactivating the parent.
    UnityEngine.Transform:set_parent(Transform)
    PoolBoss:Despawn(Transform) (at Assets/DarkTonic/CoreGameKit/Scripts/PoolBoss/PoolBoss.cs:199)
    SpawnUtility:Despawn(Transform) (at Assets/DarkTonic/CoreGameKit/Scripts/Utility/SpawnUtility.cs:38)
    Killable:Despawn(EventType) (at Assets/DarkTonic/CoreGameKit/Scripts/Utility/Killable.cs:793)
    Killable:BecameInvisible() (at Assets/DarkTonic/CoreGameKit/Scripts/Utility/Killable.cs:359)
     
  38. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    It's a Unity 4 error. They changed what they allow (and not) during disabling of objects. Let me know how you got the error please. It seems like this could happen if you tried to GameObject.Destroy it (which should never happen because you should use Pool Boss to pool).
     
    Last edited: Feb 21, 2014
  39. Chibwemwn

    Chibwemwn

    Joined:
    Feb 6, 2013
    Posts:
    129
    Okay, so I'm definitely using Pool Boss, and I'm not doing anything extraordinary. I'm just having two objects collide, with triggers, and then one of them gets despawned. both are parented objects, though, and they have they're own Killable scripts. I don't know how that affects things.
     
  40. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Ok I remember your project. I'm not sure how that will work properly with Killable not being the top-level script. I'll investigate this myself and see if it can be fixed.
     
  41. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Core GameKit v3.2 will be live in 5 minutes. Changelog:

    • Added "every frame" checkboxes to all Playmaker custom actions where it makes sense to have them.
    • Added a parameter "hasWon" to LevelSettings Listener event GameOver so you can tell whether the player won or not (both Win and GameOver events are fired when you complete all Syncro waves).
    • Fixed bug where Pool Boss would let you double despawn a prefab, making it disappear mysteriously later when re-used by the pool.
    • Fixed bug where LevelSettings.RestartWave would throw an error when no waves are set up.Added Wave Restart Mode to Level Settings. Choices are Leave Spawned, Despawn Spawned and Destroy Spawned. Destroy spawned only works on Killables and calls their Destroy method (which spawns death prefabs etc).
     
  42. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I just updated to 3.2 and get an error:

    Assets/DarkTonic/CoreGameKit/Scripts/Level/LevelSettingsPlaymakerListener.cs(33,30): error CS0115: `LevelSettingsPlaymakerListener.GameOver()' is marked as an override but no suitable method found to override
     
  43. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    The release notes for v 3.2 goes from v 3.1.9.1 to 3.1.2. I believe this is most likely a typo. It is also listed in the asset store as v 3.1.2.
     
    Last edited: Feb 21, 2014
  44. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yeah, that method signature changed. Delete your entire Playmaker Custom Actions folder (inside the Core GameKit folder) and re-import the new ones by opening the Playmaker_CustomActions package. That will take care of it for you.
     
  45. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yep. Noticed that after I submitted it. The release notes in this thread OP are correct.
     
  46. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    we cross posted. I updated that post. I meant v 3.1.2 and also noted that in the asset store it is also v 3.1.2
     
  47. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I am brand new to the Core GameKit. I am following the PDF Readme and I am to the part where you say"

    e. Just for fun, crank up the Min to spawn to 20 and the Max to spawn to 30, then drag any
    prefab into the “Prefab to spawn” box and press play. Notice how it spawns between 20
    and 30 of your prefab within a few seconds. Wasn’t that easy? Now I’ll explain the other
    settings.

    However I don't get anything spawning and I get a error. I think it is because you added Pool Boss and that is not reflected in the Readme. The errors are:

    The Transform 'Enemy' passed to Spawn is not in the Pool Boss.
    UnityEngine.Debug:LogError(Object)
    LevelSettings:LogIfNew(String) (at Assets/DarkTonic/CoreGameKit/Scripts/Level/LevelSettings.cs:853)
    PoolBoss:Spawn(Transform, Vector3, Quaternion) (at Assets/DarkTonic/CoreGameKit/Scripts/PoolBoss/PoolBoss.cs:129)
    SpawnUtility:Spawn(Transform, Vector3, Quaternion) (at Assets/DarkTonic/CoreGameKit/Scripts/Utility/SpawnUtility.cs:24)
    WaveSyncroPrefabSpawner:SpawnOne(Boolean) (at Assets/DarkTonic/CoreGameKit/Scripts/Spawners/WaveSyncroPrefabSpawner.cs:257)
    WaveSyncroPrefabSpawner:Update() (at Assets/DarkTonic/CoreGameKit/Scripts/Spawners/WaveSyncroPrefabSpawner.cs:192)


    and

    Could not spawn: Enemy (UnityEngine.Transform)
    UnityEngine.Debug:LogError(Object)
    LevelSettings:LogIfNew(String) (at Assets/DarkTonic/CoreGameKit/Scripts/Level/LevelSettings.cs:853)
    WaveSyncroPrefabSpawner:SpawnOne(Boolean) (at Assets/DarkTonic/CoreGameKit/Scripts/Spawners/WaveSyncroPrefabSpawner.cs:262)
    WaveSyncroPrefabSpawner:Update() (at Assets/DarkTonic/CoreGameKit/Scripts/Spawners/WaveSyncroPrefabSpawner.cs:192)
     
  48. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I will fix the version number in a couple minutes, as 3.2
     
  49. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Sorry I didn't respond sooner, I wasn't emailed about this particular post. Thank you for letting me know. Correct, it should say:

    Just for fun, crank up the Min to spawn to 20 and the Max to spawn to 30, then drag any prefab into the “Prefab to spawn” box and just before you press play, go to the Pool Boss prefab (explained later) under LevelSettings and click Auto-Add Missing Items. Now press play. Notice how it spawns between 20 and 30 of your prefab within a few seconds. Wasn’t that easy? Now I’ll explain the other settings.

    I'm updating the docs right now with the correction. V 3.2 will be live in about 5 minutes with this documentation fix.
     
    Last edited: Feb 22, 2014
  50. msbranin

    msbranin

    Joined:
    Jan 19, 2009
    Posts:
    104
    So curious as to how to handle a 2d Beat em up with this kit. I was thinking something in the lines of maybe a Double Dragon or Final Fight or Golden Axe type beat em up. All the videos pretty much cover a Top Down Shooter ala Galaga Type game.