Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Core GameKit! Pooling / Spawning / Combat

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

  1. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    Amazing stuff... Love this plugin. Two quick questions.

    1 - Simplest way to implement touch events for despawns and various other things for mobile? For example the Triggered Spawners/Despawners have MouseClick events.

    2 - Does KW support alternate pool plugins like SmartPool? And how would I tie it in? http://www.fluffyunderware.com/pages/unity-plugins/smartpool.php


    thanks as always!
     
  2. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    outtoplay, thank you.

    #1 - I wish the plugin could do everything! Pretty much you're going to have to write either a ray-casting "hit" small script or a ray-casting movement script, depending on the type of game controls you're after. I recommend using the Finger Gestures plugin, Easy Touch or similar so that you basically only have to write it once and the plugin will automatically handle the "touch" equivalent for you on mobile devices. That's how I started out, with the help of finger Gestures! After you get that working, you'll either be using a Trigger / Collision events on the Triggered Spawners to interact with your player.

    #2 - I didn't know about Smart Pool, thanks for bringing it to my attention. Basically KW should work with any Pooling plugin. The key to making it work is modifying the Spawn and Despawn methods in SpawnUtility.cs to use that plugins methods instead of Instantiate and Destroy. Inside SpawnUtility.cs, commented out, is the correct syntax to use Pool Manager. I expect the Smart Pool API is very similar, just a different object. If you can find out what the equivalent of the following code is for Smart Pool, it should be your ticket:

    PoolManager.Pools["YourPoolName"].Spawn(spawn, spawnPos, spawnRotation);

    That's Pool Manager code. However from what I can tell, Smart Pool documentation isn't the greatest. If you can't figure it out unfortunately I recommend to get the original (Pool Manager). The bright side is that I can answer probably any question you have about Pool Manager usage, having used it for some pretty crazy stuff.

    Good luck!
     
  3. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    Thanks Brian,

    The Pool thing sounds pretty straight forward I"ll tackle that first. I'm surprised the touch stuff hasn't come up before, I"d imagine a fair number of your users plan to deploy on mobile plats like IOS. I own Easy Touch so I guess I'll start there. Did you every get Killer Waves to work with Finger Gestures?
     
  4. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    Yeah, I imagine almost everyone using this would be building stuff for mobile :). What I'm saying is there's no way for me to simply add some no-code controls to move your game's player avatar around that would work on PC and mobile also. That's outside the scope of this plugin. Besides, those 2 plugins do a great job of it already. However, even though KW won't handle moving your player around, it will already handle collisions between the player and enemies / power-ups or whatever else, in case that part isn't clear.

    If you have a game without a player avatar, there are other ways to utilize it as well.

    Basically, handle moving your player around on the screen with the help of Easy Touch, and at that point start integrating KW and the rest should be fairly easy with those parts out of the way.

    Oh and yes I have used KW with Finger Gestures on our new game that is about 80% done :) it works well
     
    Last edited: Mar 24, 2013
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    Here's the video of V2.0 features! Enjoy.
     
  6. ProjectOne

    ProjectOne

    Joined:
    Aug 9, 2010
    Posts:
    442
    Thumps up!
     
  7. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    Epic update...nice work guys.

    For the Score Lives, is KW2.0 generating GUIText objects that are styleable as usual or do we create and assign?
     
  8. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    Thanks!

    The one shown in the demo is a GUILabel, but I recommend commenting that part out and updating your NGUI object or whatever you use instead (1 line of code). I can add a NGUIListener on my Dropbox, I just can't put in the build or it won't compile for non-NGUI users.
     
  9. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    +1 that


    also, just picked up FingerGestures based on your earlier mention of how nice it was. 3.0 is really nice. so modular. Thanks for the tip!
     
  10. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    Cool, I can't compare it to the other one you already had since I haven't used it. But yeah the FingerGestures guy fixed some initial problems I had with it after I contacted him. Great product!
     
  11. g0tNoodles

    g0tNoodles

    Joined:
    Nov 28, 2010
    Posts:
    193
    I am really enjoying this tool, glad I picked it up, made it much easier for me to attempt to get my game out. Just wish I knew more about the graphical side of things, getting muchos draw calls when spawning lots of enemies (not a modeler in any way shade or form).

    Either way, very much looking forward to the next update. Thanks for making such a good 'package' =]
     
  12. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    One way to get less draw calls is use a sprite batching system such as ex2D, NGUI (there are others). This allows you, when each object is under about 300 vertices, to have any number visible at once with a single draw call, as long as all share a single texture for the materials. This was invaluable for our first game Wall Street Titan. If you want to do a "busy" game that will run fast on older devices, it's pretty much impossible without such a helper. I hope that helps!
     
    Last edited: Mar 26, 2013
  13. g0tNoodles

    g0tNoodles

    Joined:
    Nov 28, 2010
    Posts:
    193
    Thanks for the reply. I assume these tools won't help me as I am doing a full 3D game. I get that I can assume I will get a decent amount of draw calls for doing this but I was getting something in the region of 600 (mostly due to my terrain). I have reduced the terrains quality so I have taken it down by a significant amount but obviously when I start spawning enemies in larger numbers, it can quickly climb again. I now start the game at about 60 calls but when I have 20 enemies on screen, it can reach about 170. I was looking on having quite a few more than that along with turrets too.

    Is there any other solution to this for the 3D side of things or is it simply a case of reducing the quality of my assets?
     
  14. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    Oh ok. If you can get the verts under 300 for the enemies, you can combine 16 256x256 textures into a single 1024x1024 texture and get 1 draw call instead of 16 draw calls if you had one of each enemy on screen. The largest texture you can use is 2048x2048 I believe. Other than that you are probably stuck and need to either reduce quality or target only higher end devices and hope you don't have other bottlenecks such as physics and shaders as well. That is if you're targeting mobile?
     
    Last edited: Mar 26, 2013
  15. g0tNoodles

    g0tNoodles

    Joined:
    Nov 28, 2010
    Posts:
    193
    OK, thanks for the tip.I'll see what I can do and if that's nothing, hope one of my modeller friends can help me out in some way.

    At the moment, I am targeting at least low end desktops/notebooks while also trying to make it workable in the web player. If it receives fairly well then I hope to make a mobile version. I assumed I would run in to these issues which is why I chose this direction. I am using character controllers on each AI mob atm so that may affect me later but for now the FPS is OK with little lag in that regard.

    Anyway, great work on KW, I cannot fault it at all!
     
  16. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    I forgot to mention, KW 2.0 is submitted to the Asset Store! I also got rid of some of the warnings that appear when you import the package on Unity 4.
     
  17. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    Aaaaaand, V2.0 is live! Go grab the update and try the new goodies!
     
  18. meta87

    meta87

    Joined:
    Dec 31, 2012
    Posts:
    254
    Awesome! Grabbing it now.
     
  19. meta87

    meta87

    Joined:
    Dec 31, 2012
    Posts:
    254
    Okay so I've spent a little time messing with V2.0. Great job! The On Enable/Disable option is just what I needed. Lots of other cool stuff too. I haven't run into any issues.
     
  20. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    Good to hear meta87, keep me up-to-date if you can think of stuff that would be cool to add.
     
  21. dark_tonic

    dark_tonic

    Joined:
    Mar 23, 2011
    Posts:
    133
    Tower Defense and RTS devs, please PM me, we want to make sure you're taking full advantage of the workflow improvements in 2.0 (they should be quite intuitive, though) and I have a quick question for you!

    $tower_defense_game_anomaly_warzone_earth_hd_for_iphone_ipod_touch_and_ipad_1.jpg
     
  22. Zink

    Zink

    Joined:
    Mar 21, 2013
    Posts:
    4
    $ScreenCap.jpg

    KillerWaves 2.0

    I don't get the expand / collapse drop down arrows for the Killable utility (fesh scene / fresh project) using Unity 4.1.0f4. Is there something that I need to do first or click on? PDF shows them on by default.
     
  23. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    No there's nothing you need to do. That's very strange. I will try importing the package on my V4.1, take a look and report back very soon.
     
  24. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    Indeed I am replicating your problem. I'll make a fix and post a zip of just the files needed to fix it. Hang in there!

    It seems that Unity 4 doesn't like indentLevel = -1 in custom Editor scripts.
     
    Last edited: Mar 30, 2013
  25. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    Ok Zink (and other V4 users), just unzip this and copy it over the top of your KillerWaves/Editor folder and it will fix the problem. The problem was occuring on multiple inspector scripts. I tested it in V 3.5.7 and V4 with the changes and it looks a-ok.
    https://dl.dropbox.com/u/68729518/DT/KW_Editor.zip

    Hotfix has been submitted to the Asset Store as well. Let me know if you have any other problems.
     
    Last edited: Mar 31, 2013
  26. Zink

    Zink

    Joined:
    Mar 21, 2013
    Posts:
    4
    Fixed, thanks again for the quick reply, digging the new version and new features!
     
  27. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    No problem, thank you for posting here so I could fix it instead of posting a negative review.
     
    Last edited: Mar 31, 2013
  28. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    Ok, V 2.0.1 appears to be live in the Asset Store (although I didn't get an email telling me). That hotfix should be live. If anyone still has the problem mentioned by Zink after downloading a new version, please let me know! Now if you don't mind I have a few new things to add to the plugin!

    Also, we are having a reduced price sale right now on both our plugins so be sure to check them out if you have not :)
     
    Last edited: Apr 4, 2013
  29. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    I just submitted V2.1 to the Asset Store. Here's what's new.

    - Killable Death Prefab now can pull from Prefab Pools.
    - Killable now has Damage prefab section. You can spawn something whenever hit or spawn x of the prefab for every Y hit points lost.
    - Added optional minimum distance limiter for syncro spawners. All spawned items must be min distance away from spawner before another will be spawned.

    Keep those requests coming! The last one was from a tower defense game-maker.
     
  30. ProjectOne

    ProjectOne

    Joined:
    Aug 9, 2010
    Posts:
    442
  31. ProjectOne

    ProjectOne

    Joined:
    Aug 9, 2010
    Posts:
    442
    Hi,
    just started a new small project with Killer Waves.. is it still the case where if using PoolManager4, I better only use one single spawn pool? Or as something changed where I can make use of multiple spawn pools (for organisation/other purposes).

    Thanks
     
  32. Juntaou

    Juntaou

    Joined:
    Apr 7, 2010
    Posts:
    25
    Hey thanks for putting this on sale, before I grab it I wanted to ask about a question I mentioned on your thread for your free version. Do you think you will be adding the ability to spawn or not spawn based on a trigger? For example a player steps on a trigger which spawns a new wave of baddies? Or a player leaves a trigger and this will cause a new wave to spawn. The games I have in mind can't use a set timer to spawn the waves, they would be based more off of events so I have complete control over the when things are spawned.

    *edit*

    I just noticed your last post thanks for that addition, I will go grab it now! Also the addition I just mentioned would be awesome! Thanks!
     
  33. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    Yes, the current code only supports a single spawn pool. If you can think of a way / place in the UI where I should have a setting for which spawn pool things should despawn into, let me know and I'll get that in the next update.
     
  34. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    The full version has an entire different set of spawners called Triggered Spawners which can spawn waves from 13 different events, including OnTriggerEnter and OnCollision, with layer and tag filters (you can even have any number of child spawners that talk to each other). Watch the 3rd and 4th videos in the OP here to see how easy they are to set up. For games I'm making Triggered Spawners are used almost exclusively.
     
  35. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    Killer Waves 2.1 is live! Download it now :)
     
  36. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    Just submitted a hotfix for V2.1. Updates were:

    - Fixed bug for "not visible for time" mode on Killable.
    - Fixed bug for warning when having no music during waves.
    - Fixed VS-unfriendly yield returns.

    If you need these fixes before it goes live, grab the files right here
     
  37. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    I justed wanted to say thanks for the Smooth Moves recommendation. We just picked it up for our next game and it looks like it will help out a lot!
     
  38. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    Very welcome. It's a terrific plugin. And I just purchased PoolManager4 on your recomendation so we're even.
    Still need to send you stuff, will do so Friday. As my wife often complains. "I must have seen a shiny thing" and got distracted...:eek:

    best,
    B.
     
  39. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    Sounds good outtoplay lol shiny thing.

    BTW, V2.1.1 is live! go grab the bug-eliminated version everyone!
     
  40. zeeawk

    zeeawk

    Joined:
    Sep 12, 2012
    Posts:
    67
    Is there anyway to have Killer Wave detect if something is where it is trying to spawn and skip that spawn or change position and try to spawn again?
    I know there is the random x,y,z stuff and wait for unit to be so far away but I didn't see anything like that.
     
  41. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    As you said, it can check that things spawned from the same spawner are a minimum distance away before spawning more. That was added in 2.1. Also if you are spawning gravity rigidbody objects with colliders, newly spawned things should bump other things out of the way when they're spawned, which may or may not work for what you want.

    A ray cast could probably accomplish what you want, but I'm reluctant to add in code like that when it would need to run every frame on every spawner. That could bring a mobile game to its knees from a performance perspective. Of course it would be an optional thing and only usable for non-mobile games I believe. I'll put it in the list for possible future enhancements.
     
    Last edited: Apr 27, 2013
  42. zeeawk

    zeeawk

    Joined:
    Sep 12, 2012
    Posts:
    67
    Cool.
    I'm thinking if you had a building next to a spawner and you still wanted a random x,y.
    Or a vehicle that drove over/by a spawner. You wouldn't want something spawning in/on the vehicle.

    Another interesting option would be not to spawn something from a spawner if the player was currently looking at it.
    Makes games feel more real to me when you don't see bad guys spawn on screen.
     
  43. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    I agree, you don't wanna see guys spawning unless it's like Gauntlet, or spawning projectiles and stuff like that. I normally keep all my enemy spawners offscreen. For a building scenario, you could use a random X only and then put another spawner close by with a random Z only so they would avoid spawning on top of the building in all cases. That would be a workaround.

    If the vehicle is on top of the spawner but the spawner is offscreen, it shouldn't usually matter what weirdness you're spawning as it isn't visible to the player until they move onscreen, no? It's something that would be cool to fix, but yeah I don't want to add ray casts in to this. All the code needs to be great performance for mobile.

    I like the visible = no spawn option. I'll add that to the next version for syncro spawners :)
     
    Last edited: Apr 28, 2013
  44. zeeawk

    zeeawk

    Joined:
    Sep 12, 2012
    Posts:
    67
    Very cool and good advice.
     
  45. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    I just submitted V2.2 to the Asset Store. This is just a performance fix suggested by a user who emailed me. It makes the Syncro spawner's performance a lot better for elimination and repeating waves. They will actually performance scale superbly thanks to the new event-driven code.

    Thank you for the suggestion!
     
    Last edited: May 2, 2013
  46. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    V 2.2 is live! Download away.
     
  47. bravery

    bravery

    Joined:
    Mar 26, 2009
    Posts:
    270
    hello jerotas,

    I'm wondering if your nice spawning tool can spawn objects just like fruit ninja does?

    where the fruites spawnes from different places (from the ground) some of them with different angles, sometimes the wave spawn one or two and sometimes will spawn 7 or 8 in every wave, sometimes the spawned object will follow each other and sometime the spawned will puch all the objects togather.

    If you play fruit ninja or similar game you will understand what I mean.

    Thanks.
     
  48. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    I've played Fruit Ninja quite a bit, great game! Yes Killer Waves can easily accommodate that sort of behavior. There are random angles and placement options. However there are no limitations on the angle to make sure the random angle always points toward the visible part of the screen. So that sounds like something that should be added, I will put it on the list for the next version. Aside from that, you could make an Angling script to attach to the spawned objects in just a couple lines of code if you write code.

    Thanks for the question.
     
  49. bravery

    bravery

    Joined:
    Mar 26, 2009
    Posts:
    270
    what about the random wave generation? and generate from differnt places?
     
  50. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,474
    Sorry, I forgot to address that. Yes those are both provided. You can specify a min and max wave size, and it will choose randomly for each wave. Also there is a location randomizer, you specify the max X,Y and Z distance to vary by.
     
unityunity