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
    Awesome! I've been meaning to check out your plugin. Now is the perfect time.
     
  2. MetallimaN

    MetallimaN

    Joined:
    Mar 11, 2015
    Posts:
    20
    Hi,
    Is there a setting or a way in code to despawn a game object(projectile) after it has traveled a certain distance or after a few seconds?

    Thanks
     
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yes, "use death timer" on Killable's "Despawn and Death Triggers" section. If you're not using Killable, then you can use TimedDespawner.

    Nothing for distance, you'd need to code that yourself.
     
  4. MetallimaN

    MetallimaN

    Joined:
    Mar 11, 2015
    Posts:
    20
    Now for a problem that I have been having....I am spawning my projectile using the PoolBoss.SpawnInPool method.
    My first few projectiles all work nicely but if my player gameobject changes direction, my projectile doesn't appear to call its script. The projectile is spawned but doesn't move....and it doesn't hit any breakpoints in the projectile script either. If I keep firing projectiles, some do correctly call the script and some don't.
    Other than using the PoolBoss.SpawnInPool method, is there any other way to spawn a projectile when tapping the screen?
     
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    The only thing I can suggest is that you make sure your script calls initialization code in OnSpawned. If it's in Awake or Start methods, that will only get called on the first spawn of the prefab. After it despawns and respawns again, the code will not get called.

    We have had zero problems with Pool Boss and we use it extensively.

    PoolBoss.Spawn methods are all you will ever need.
     
  6. MetallimaN

    MetallimaN

    Joined:
    Mar 11, 2015
    Posts:
    20
    That was the problem. I didn't realize that Start was only called on the initial spawn and not on every spawn. Moved the code to OnSpawned and everything works perfectly.
    The level of support on this asset is incredible.
    Thanks so much.
     
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No problem. There are some things in the manual like this that are definitely not obvious :) I know it's long.
     
  8. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Some cool updates are coming very soon!

    - Option to have a Killable die after it travels X distance from spawn location.
    - Categories for Pool Boss!
    - Allowing hits with non-Killables to cause death of other Killables.

    and more!
     
    I am da bawss likes this.
  9. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    .


    Found an error in the latest version:



    Assets/Darktonic/CoreGamekit/Scripts/Spawners/TriggeredSpawner.cs (644,25); error CS1061: Type 'Button' does not contain defintion for 'onClick' and no extension method 'onClick' of type 'Button' could be found (are you missing a using directive or an assembly reference?)




    Sounds great! Can't wait to see it! :)
     
    Last edited: Jun 18, 2015
  10. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    That's fixed in the next version. It only happens if you have another script named "button" in your project.

    If you don't want to wait for me to submit it and get it approved, email me at support@darktonic.com for the new beta.
     
  11. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574

    LOL, I don't believe it. I thought UT fixed this Namespace problem back in Unity 4 didn't they? I know Unity 3 didn't support Namespace but Unity 4 (which is the version I completely skipped) was supposed to have already solved that by supporting it. So if I have a generic name for script I risk colliding with another one again?
     
    Last edited: Jun 18, 2015
  12. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    It's not Unity's fault. It's mine for not casting to a full namespaced typed based on ReSharper's suggestion (ReSharper can be wrong and was this time).
     
  13. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Core GameKit V 3.2.6.1 has been submitted to the Asset Store. Lots of cool additions! Changelog:

    • Added NodeCanvas integration optional package to our plugin.
    • Added "Spawn on Death Hit" checkbox (defaults to off) for Damage Prefabs, so you can choose to have damage prefabs during the final death hit or not.
    • Added Incremental Offset (Vector3) to Killable's Damage Prefab section, to add to the position of each additional Damage Prefab after the first.
    • Added Incremental Offset (Vector3) to Killable's Death Prefab section, to add to the position of each additional Death Prefab after the first.
    • Added "Allow Non-Killable Hits" checkbox when using HP Death Mode of "Collision or Trigger" for Killable. This allows you to permit collisions with a non-Killable to cause the Killable to die!
    • Fixed bug where having another class named "Button" in your project would cause a compilation error in CGK.
    • Fixed all compile warnings for Unity 5.1
    • Added "travel distance death" section to Killables so they can automatically die after moving X distance from spawn point.
    • Added category feature to Pool Boss (for visual organization only). Each category's items are alpha sorted and the categories can be shifted up and down.
    • Removed alpha sort and shift up / shift down buttons from Pool Boss.
    • Add color coding to Pool Boss during runtime to show which Pool Items have nothing spawned (red) and things spawned (yellow).
    • Added "Triggered Spawner Activate Wave" task for Behavior Designer.
     
  14. VectorNector

    VectorNector

    Joined:
    May 22, 2013
    Posts:
    62
    Hey,
    I'm building a first person RPG and my level setting is set to elimination. It's also set up to repeat endlessly so if you kill one game object, a new one pops up its place and only one at a time. I'm using the Take Damage action in Playmaker to inflict damage. My problem is I can't seem to target the active game object. In Playmaker, I've tried using the Find Closest and Find Game Object actions. I've got the events log turned and it's showing me that I'm inflicting damage to inactive game objects. What's a good way to target the active one?

    Let me know if you need screenshots or anything.
     
  15. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Explain what you mean by "active game object". I don't believe there's any concept like that in Core GameKit, but it depends what you mean.
     
  16. VectorNector

    VectorNector

    Joined:
    May 22, 2013
    Posts:
    62
    In Playmaker I'm looking for game objects by tag name, but the problem is that all the cloned game objects have the tag named Enemy. What's happening is I'm inflicting damage to Clone 1 or Clone 2 which are inactive and not visible. Clone 5 is the game object that's in front of the camera and has the active checkbox enabled.




    If you have any ideas on how to target the game object that's visible, I'd love to hear your thoughts. I can always write something in C#. Worst case scenario-I'll shoot a game object without a mesh to the crab sprite.
     
  17. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    vectornector, Each SyncroSpawner has a private _spawnedWaveMembers variable, containing a list of the still spawned objects. I could add a public accessor property for that and you can read it. That would work. You can wait for the next update or do what I said yourself.
     
  18. VectorNector

    VectorNector

    Joined:
    May 22, 2013
    Posts:
    62
    That would super awesome. I don't want to mess with your code because I'll probably end up introducing 110 new bugs. I can wait for a way to get a list of public spawned member's variables. What's weird is I also tried checking the visibility of the deactivated gameObjects and it comes back true. I should see if I'm checking the parent object by mistake.

    I appreciate your help. Thank you so much!
     
  19. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I wouldn't check visibility, check if they're active or not :)
     
  20. jprocha101

    jprocha101

    Joined:
    Apr 8, 2015
    Posts:
    134
    @jerotas

    Do you guys have any plans to add knock back speed to the Killable script? It is kind of slow right now.

    I am loving all the features so far. This is truly an amazing asset.
     
  21. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    The knockback is instantaneous and only happens for 1 frame. If it's too slow, crank up the value.
     
  22. jprocha101

    jprocha101

    Joined:
    Apr 8, 2015
    Posts:
    134
    Hmmm... I have an enemy getting knocked backed after colliding with my player and the knock back is about 2 seconds long.

    What do you mean by crank up the value? I have it 5 and 5 right now.
     
  23. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    When I was testing the functionality I put knockback up to 50. Try some higher values.

    As far as 2 seconds, that's probably just physics bouncing and momentum and such after the 1-frame knockback.
     
  24. SketchWork

    SketchWork

    Joined:
    Jul 6, 2012
    Posts:
    254
    Hi Brian,

    We have recently integrated both Master Audio and Core Game Kit into our games. I have a couple of questions first about the best way to set up pooling for our use.

    1) We have hundreds of coins jotted around the play area which I want to use in Core Game Kit's PoolBoss. They are already in the correct position in the game area. I can do this by selecting "Auto Add Missing Items" which works fine.

    2) I also have Bad Guys around the area which are set up in the same way and also works great.

    3) We also have spawning enemies which we use a different category for.

    When I call despawn the AutoAdded items just go into the top category. Is there any way to assign them to a category on despawn?

    Both your kits are a great help.

    Thanks for everything,

    Justin
     
  25. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    If the item doesn't exist in any category, it will be auto-added to the top category (same when you create a new pool item). So I assume you never added it to Pool Boss and are relying on auto-add to create the pool item at runtime. To fix, just add it to Pool Boss (in edit mode) with 1 item pre-loaded - in a different category - even though you're not spawning from there initially.
     
  26. SketchWork

    SketchWork

    Joined:
    Jul 6, 2012
    Posts:
    254
    Ahh, no problem. That is what I did. Just wanted to make sure there wasn't anything I was missing. Maybe you could allow adding them to an item in PoolBoss with zero pre-loaded prefabs for this kind of purpose?

    All the best,

    Justin
     
  27. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    That should also work :). Let me know if it doesn't. But if it doesn't, it's not really a big deal to have 1 copy of the prefab waiting there.
     
  28. jprocha101

    jprocha101

    Joined:
    Apr 8, 2015
    Posts:
    134
    @jerotas

    Have you guys ever thought about making a UI or new tab to display some items in graphical form?

    For instance, if we have 20 enemies with Killable scripts it would be much easier to try out different combinations of hit points, attack points, etc. if we could see them all at once.

    That might be asking too much though :)
     
  29. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I'm not sure how hit points and attack points translates into anything visual...

    But we do in the next version have "visualization" of Triggered Spawner waves and Syncro Spawners already have them too.

    If you're asking for something else, please clarify because I'm not sure what you mean.
     
    jprocha101 likes this.
  30. jprocha101

    jprocha101

    Joined:
    Apr 8, 2015
    Posts:
    134
    I meant something like a table view in the inspector not directly in the scene view. Each row would be a Killable. The columns would be the Killable attributes.

    The reason I mention this is because I have about 30 enemy prefabs each with their own Killable script. I wanted to raise the attack points for some of them by 1 or 2 and the HP by 1 or 2, then run the game and see if it that amount made sense for that level. If not then increase by another couple points and run the game again. In order to do that I had to go through all 30 prefabs one at a time and adjust, then run the game, go through all 30 prefabs again then run the game, and repeat.

    It makes for a very tedious workflow having to go to each Killable script, find the attributes I want to change, change it, then find the next prefab with a Killable script, etc. One inspector tab with a concise view of all Killables where I can quickly adjust a value then go to the next would be very beneficial. Especially since there are so many options on each Killable script it can get very cumbersome navigating between them in the inspector.

    Again that might be asking too much :), but I hope that made more sense. Thanks.
     
  31. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Ok I see what you mean. Yeah that's kind of a PITA and no real way to make that happen, but I think I can help you deal with that with existing features.

    You can use World Variables for that. Assuming there is some overlap with more than 1 prefab having the same attack points or hit points, you would just need to change the World Variable start value to change the hit points of the X prefabs that use that World Variable for hit points.
     
  32. jprocha101

    jprocha101

    Joined:
    Apr 8, 2015
    Posts:
    134
    Ah, that would help some. Yeah it is kind of a PITA, but its actually like that with other components too so I blame Unity :)
     
  33. jprocha101

    jprocha101

    Joined:
    Apr 8, 2015
    Posts:
    134
    @jerotas
    Hey I one more question, promise, just the lol.

    Using a syncro spawner is there a way to immediately spawn the first gameobject immediately when the wave starts?

    Say I have min and max to spawn of 5 and 60 seconds to spawn all. I want the first one to spawn, then 12 seconds later the next object, and so on. Right now it seems to wait 12 seconds to spawn the first object even though "Delay Wave" is set to 0.
     
  34. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No there isn't. I'll add that to the roadmap.
     
    jprocha101 likes this.
  35. jprocha101

    jprocha101

    Joined:
    Apr 8, 2015
    Posts:
    134
    Good deal, thanks.
     
    jerotas likes this.
  36. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Core GameKit V 3.2.6.2 has been submitted to the Asset Store. Changelog:

    • Added property SpawnedWaveMembers to Syncro Spawners to get a list of items spawned and not yet destroyed of the current wave.
    • Added checkbox to Visualization Waves of Triggered Spawners just like Syncro Spawners have!
    • Added check in Pool Boss for Trail Render or Particle Animator components with auto-destruct enabled and show a warning in the Inspector if so. Pool Items should never be destroyed, only despawned!
    • Added "StopDeathTimer" and "StartDeathTimer" methods to Killable.
    • Fixed bug: Visualize Wave in Level Settings (showing multiple spawner waves all at once) only worked if that Global Wave is not collapsed.
    • Fixed bug: With multiple waves having visualization turned on for a Syncro Spawner, only the lowest one gets rendered always.
     
  37. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    1 - Does Core game kit support Ray weapons or light beam weapons like for example lasers? As on these ones you do not fire any object, is done with ray cast

    so can the player or enemy use for example a laser to destroy each other?

    2 - Can a player have multiple weapons choice (using ONLY ONE weapon each time, I mean only one active weapon) that could be choosen from a list?

    3 - Can a still and static wall be killable? I mean if instead of having a moving enemy, a wall that is an obstacle in the way could be considered an enemy, and then if add a killable script to the wall, would be able to be destroyed?

    4 - Will there be anytime that you could make a REAL 3D example or demo scene showing the features of Core Game kit? I know that the 2D looking space shooter is really made with 3D components, but I mean to have a real 3D scene with 3D objects in a simple 3D environment, it could be done with simple primitive shapes, I think this would be very helpful and useful

    Thanks very much for any possible help

    Best wishes
     
  38. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    #1, "support" - yes, meaning you can do that but you'll need to code it. Killable has a TakeDamage method you can call from whatever.
    #2, you would need to code the weapon switching part. You can set up multiple Custom Event waves, one for each weapon or more, for just the weapon projectile spawning patterns.
    #3, it can be a normal Killable (taking damage) only if a Collisions or Trigger registers. Before, when I marked thing as static, no collisions or trigger would fire, which means no. I haven't tried in 2 years though. Let me know. If collisions or triggers don't register, you could still call TakeDamage on the Killable if you can detect them somehow.
    #4, it's on the roadmap. Lower priority so probably won't happen for months at a minimum. I'm also about to have twins born so new features will be coming slower for a bit.
     
  39. VectorNector

    VectorNector

    Joined:
    May 22, 2013
    Posts:
    62
    Hey @jerotas, how do you access the SpawnedWaveMembers stuff? I don't know where to start. Thank you so much for adding this feature!
     
  40. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    It's this property of WaveSyncroPrefabSpawner.cs.

    Code (csharp):
    1.  
    2. /// <summary>
    3. /// Returns a list of Spawned Wave Members
    4. /// </summary>
    5. public List<Transform> SpawnedWaveMembers {
    6.    get {
    7.       return_spawnedWaveMembers;
    8.    }
    9. }
    10.  
    You could make a public variable of type WaveSyncroPrefabSpawner and drag the spawner in, then read the property.
     
    VectorNector likes this.
  41. VectorNector

    VectorNector

    Joined:
    May 22, 2013
    Posts:
    62
    That worked beautifully. I can't thank you enough for your help. I swear this asset is like Franks RedHot cause I put this *bleep* in every prototype that I make. Now I can expand my other ideas.
     
  42. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Same here :)

    Keep up the good work yourself, and let us know when your game is released! We'd like to check it out.
     
  43. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Heads up to all users: tomorrow morning I'll be a father of 2 twin boys :)

    So support will be a little slower for a little while. I advise posting to our support forum or here and sometimes other users may be able to help out before I can.

    I'll be back to former awesome support levels very soon, so hang in there!
     
  44. danreid70

    danreid70

    Joined:
    Aug 28, 2010
    Posts:
    225
    Congratulations! Twins... Oh boy...
     
    jerotas likes this.
  45. jprocha101

    jprocha101

    Joined:
    Apr 8, 2015
    Posts:
    134
    Maybe someone can help me out.

    I have a prefab I am spawning using Pool Boss when the user clicks the mouse and releases the mouse button.
    Code (CSharp):
    1. Transform bulletClone = PoolBoss.SpawnInPool(Bullet.transform, Vector3.zero, Quaternion.identity);
    The bullet clone will have a script as a component called BulletMove, and that script will make the bullet move towards the mouse click position and keep going in that direction.

    Problem is that I need to set the mouse position in BulletMove, but the SpawnInPool method only passes back a Transform. So I cannot access the mouse position field in BulletMove because the object I get is just Transform. Using GetComponent is not working.

    Does anyone know way for to be able to access the BulletMove script from the Transform Pool Boss returns?
     
    Last edited: Jul 23, 2015
  46. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Normally that would just be:

    Code (csharp):
    1.  
    2. var t = PoolBoss.SpawnInPool();
    3. var bullet = t.getComponent<BulletMove>();
    4. bullet.position = some vector3 field.
    5.  
     
  47. jprocha101

    jprocha101

    Joined:
    Apr 8, 2015
    Posts:
    134
    I do not want to set the position of the bullet. That will always have an origin of where the gun is. There is a field in the BulletMove script that is the direction I want the bullet to move towards. That field is what I was trying to set.

    I ended up figuring it out though. GetComponent did work, but I had to set a bool in the script to make sure the bullet didn't start moving until after the field was set.

    Thanks!
     
    Last edited: Jul 24, 2015
    jerotas likes this.
  48. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433
    I have set it so that each wave has a separate music track but when I launch the game it throws this error:


    WaveMusicChanger is not attached to any prefab with an AudioSource

    component. Music in Core GameKit LevelSettings will not play.

    UnityEngine.Debug:LogError(Object)


    Which object should I attach the audiosource component too?
     
  49. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Answered your email with the same question, but whatever game object you attached WaveMusicChanger to also needs an Audio Source component.
     
  50. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433
    Thanks for the response, I attached the wave music changer and audio component to the main camera, works fine now :)
     
    jerotas likes this.