Search Unity

  1. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  6. Unity 2017.3 beta is now available for download.
    Dismiss Notice

[RELEASED] Crux - Procedural AI Spawner for Terrains (Biomes, Population Caps, Groups, and more)

Discussion in 'Assets and Asset Store' started by BHS, Dec 13, 2016.

  1. Gunsrequiem

    Gunsrequiem

    Joined:
    May 17, 2017
    Posts:
    71
    Hello, BHS!

    I just purchased both Emerald AI and Crux, and I must say I'm very excited to get them implemented with my project: Siegescape.

    Emerald AI is working perfectly, although I would like to ask you a couple of things if you have the time.

    First and foremost, I am utilizing the "Third Person Controller" by Opsive, and I was wondering if you have a way to have the damage caused by that asset to directly impact the Emerald AI objects. For now, I am utilizing the "Health" script that comes with TPC, but it's not as dynamic as it is not called within the Emerald AI object.

    Second, I'm having some issues getting Crux to work with Voxeland in that it is not spawning based on the textures selected. Since Voxeland is a voxel engine, I thought it might be due to the terrain textures being called throughout the entire height of the terrain (since it is filled, not planar), so I set it to call the rock textures that are placed on top of the actual terrain, thus ensuring the spawn is called on above-ground objects. However, this doesn't seem to work. Any thoughts on how I might create a workaround for this?

    I look forward to response, and I want to thank you in advance for your time regarding this matter.

    ~Mike
     
  2. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973

    Hey Mike!

    I can reach out to the developers of Opsive TPC to see if we can find full support with Emerald. Currently, we have a copy of the non-source code version so it isn't possible to see how its damage is called directly.

    It sounds like Voxeland isn't currently supported because Crux currently only works with Unity terrains. However, the 1.4 update, that is currently being worked on, will add tons of new features as well as mesh support, which should allow you to spawn on Voxeland terrains.

    As for texture lookup, that depends on the Voxland plugin. I looked through its documentation, but didn't see anything about getting a texture from a certain point. I can also reach out to this developer to see if we can find a solution for you.
     
  3. Gunsrequiem

    Gunsrequiem

    Joined:
    May 17, 2017
    Posts:
    71
    Thanks for the reply!

    I am currently working on a separate portion of the game that utilizes terrains, so for now it's okay to not have the functionality. Down the road, after 1.4 is released and you have implemented the mesh feature, I will toy with that to determine if I can get Crux to spawn.

    As for integration with TPC, that would be extremely helpful. I saw on the forums that you explained how to call the damage parameters with UFPS and others, but TPC wasn't included. I suppose for now, I can dig around and try figure out how to do it myself. If I do end up doing so, I will make sure to post it here since at least one other person asked about TPC integration.

    Thanks again!
     
  4. v_mace_v

    v_mace_v

    Joined:
    Feb 13, 2016
    Posts:
    20
    Do you have a rough idea of when the mesh support update might be ready?

    Cheers!
     
  5. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    Sounds good and you're welcome!


    Hey there!

    Version 1.1 will add support for mesh support. Version 1.1 is currently being worked on and should be submitted within the next few weeks, if everything is on schedule.
     
    v_mace_v likes this.
  6. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    Hey everyone,

    Just thought I'd share some information regarding the development of Crux 1.1. This update will bring some new features as well as some huge performance increases. The update should be submitted within the next few days. The other features that have been mentioned will come shortly after the 1.1 update as the feature below we the most important and most requested.

    The built-in object pooling system has been implemented with Crux and it works great. It can also dynamically expand to accommodate customizable population caps, if needed. The object pooling option allows an increase in performance of roughly 200% to 400+%, compared to using instantiation option. However, Instantiation is still an option for those who want to use it.

    The spawning node system has been implemented and allows AI to be spawned to spawning nodes. These spawning nodes allow AI to be deactivated until within a customizable range from the player. This helps with performance by not wasting it on AI that are too far away from the player. This feature works with both the object pooling and instantiation options, but is completely optional.

    ObjectPoolingAndSpawningNodes.png

    Flying and water AI options have been added. This will allow users to spawn both flying and water AI using Crux. The option is available in the AI's object tab. The range that the AI can be spawned is randomly generated based on the minimum and maximums set by the user.

    WaterAndFlyingAITypes.png
     
    Last edited: Jul 2, 2017
    v_mace_v, Stormy102 and Hitch42 like this.
  7. Gunsrequiem

    Gunsrequiem

    Joined:
    May 17, 2017
    Posts:
    71
    Can't wait! It's gonna be awesome!
     
  8. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    2,284
    Is MegaSplat support in yet?
     
  9. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    Thanks!


    I'm going to see if it can be squeezed in, but I'm not sure how hard implementation will be. If it's not added with the 1.1 update, it will be added shortly after.
     
  10. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    I looked into this, and while possible, it would take too long to implement before the 1.1 update is planned to be submitted. The 1.1 update required quite a bit of work and includes few important improvements. So, the 1.1 update should be submitted by this weekend and the 1.2 update should come within 2 to 4 weeks after that. The Crux roadmap section has been update to reflect what will be included with the 1.1 update and what will be included with the 1.2 update.

    For you, and anyone else who is interested, UniStorm support is already being worked on for the 1.2 version. UniStorm will need to have its own update in order for support to be possible as it needs to have a new script to add a custom preprocessor directive so the UniStorm features will only compile if UniStorm is present. The support will allow Crux the ability to spawn AI according to the time of day, weather, season, and more.
     
  11. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    2,284
    Thanks for the update.
     
  12. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    You're welcome.
     
  13. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    v_mace_v likes this.
  14. Ramulos

    Ramulos

    Joined:
    Feb 19, 2017
    Posts:
    20
    Hello,

    I recently bought Emerald Ai and Crux and was wondering if you could help. I used Gaia to create a terrain and then texture it. I implemented Emerald AI to my objects and the Crux to procedurally spawn them and it was working perfectly. I ran my Gaia terrain through the PolyWorld mesh converter to get a low poly style. The conversion removed the terrains textures and uses a material instead. Now Crux cant work on my terrain due to textures not being present.

    Is there any way to use Crux with a material? if anyone has used PolyWorld is there a way to preserve the textures?
     
  15. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    Hey there!

    Currently, only Unity Terrains are possible. However, with the 1.2 update, mesh support will be added.
     
  16. Ramulos

    Ramulos

    Joined:
    Feb 19, 2017
    Posts:
    20
    Thanks alot for the quick reply. Seeing as 1.1 update was just submitted Saturday 1.2 wont be out anytime soon. Though I'd love to have beta access if that's something you do for when mesh support find its way into beta.
     
  17. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    You're welcome!

    Crux 1.2 will be worked on while Emerald 1.4 is being worked on. I'm hoping the Crux update will take a about a month. You can certainly have beta access to Crux 1.2 when its ready.
     
  18. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    Hey everyone!

    Crux 1.1 has been accepted and is now live on the Asset Store!

    This update will bring some new features as well as some huge performance increases.

    Built-in Object Pooling
    The built-in object pooling system has been implemented with Crux and it works great. It can also dynamically expand to accommodate customizable population caps, if needed. The object pooling option allows an increase in performance of roughly 200% to 400+%, compared to using instantiation option. However, Instantiation is still an option for those who want to use it.

    Spawning Nodes
    The spawning node system has been implemented and allows AI to be spawned to spawning nodes. These spawning nodes allow AI to be deactivated until within a customizable range from the player. This helps with performance by not wasting it on AI that are too far away from the player. This feature works with both the object pooling and instantiation options, but is completely optional.

    ObjectPoolingAndSpawningNodes.png

    Flying and Water AI support
    Flying and water AI options have been added. This will allow users to spawn both flying and water AI using Crux. The option is available in the AI's object tab. The range that the AI can be spawned is randomly generated based on the minimum and maximums set by the user.

    WaterAndFlyingAITypes.png

    Redone Export to .txt Feature
    Crux's exporting feature has been improved as well as had some bug fixes. The exporting feature will now open up a saving window for you to save the generated .txt Spawn ID file. The AI's Category and Biome have also been added to the .txt file for better organizing.

    Updating to Crux 1.1
    Because users may have complex and large biomes, this update is intended to work without having to remove Crux prior to updating. Since there have been newly added lists within the Crux system, code has been added to dynamically add and expand the lists as needed to avoid errors. This goes for all biomes, categories, and objects.

    Coming Soon with Crux 1.2
    • Full UniStorm support to allow AI to spawn according to UniStorm's time of day, season, and weather.
    • Full Support for MegaSplat
    • Option to not spawn to textures
    • Mesh support
    • Spawn around tag option to spawn around areas such as camps, caves, city, etc.
     
    v_mace_v and Stormy102 like this.
  19. Gunsrequiem

    Gunsrequiem

    Joined:
    May 17, 2017
    Posts:
    71
    Any chance you'll be integrating Tenkoku in the same way as UniStorm at some point? That sounds like an amazing possibility for a more realized and dynamic world!

    I look forward to trying 1.1 :)
     
  20. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    Hey there!

    There's no plan to implement Tenkoku with Crux. However, if the creators of Tenkoku want to add support for Crux, that's entirely up to them. UniStorm integration is an added bonus for those who have both UniStorm and Crux :)
     
  21. KIR99

    KIR99

    Joined:
    Feb 21, 2017
    Posts:
    15
    Hey there, i'm just having a small issue with the updated Crux1.1, right now it doesn't allow me to spawn any animals or at least spawns one of them and I get the following error in runtime:

    ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index

    System.Collections.Generic.List`1[UnityEngine.GameObject].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    Crux.AssignRarityCategories () (at Assets/Crux - Procedural AI Spawner/Scripts/System/Crux.cs:356)
    Crux+<InitializeCrux>c__Iterator1.MoveNext () (at Assets/Crux - Procedural AI Spawner/Scripts/System/Crux.cs:273)
    UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    Crux:Start() (at Assets/Crux - Procedural AI Spawner/Scripts/System/Crux.cs:262)



    Regarding the settings,
    I strictly have Crux for spawning Wildlife,
    I don't have any object pooling plus the spawn type and player Transform type is set to Standard. The only changes i've made to the Crux.cs script was that I've added a line in void start to auto assign the _PlayerObject transform to the player. (which i don't think is the cause this issue, since it worked fine last time)

    _PlayerObject = GameObject.FindGameObjectWithTag("Player").transform;

    It's also worth noting that within all the biomes are retained from the previous version and my animals within Wildlife are set to "common" rarity and the odds of spawning is set to 100.

    Could I have done something wrong in the settings which might have caused the "ArgumentOutOfRangeException" issue? Or could it be something to do with Terrrain Data in my scene?

    Any help would be greatly appreciated, thank you! :)
     
  22. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    Hey there!

    Strange, there shouldn't be any issues. The only thing I can think of is the new lists that were added with the 1.1 update, but these are supposed to be fixed automatically if you are updating from a previous version. Are you receiving this error during Runtime or while in the Editor?

    Those settings shouldn't be causing any issues. Have you tried creating a new Crux system to see if the problem is still occurring?

    If you can, try enabling object pooling to see if this fixes the error.

    Also, Crux has a built-in option for instantiated players. The Player Transform Type "Instantiate" option does almost the exact same thing that you've added and grabs the player by name during start.
     
  23. KIR99

    KIR99

    Joined:
    Feb 21, 2017
    Posts:
    15

    I ran through various tests and whatnot and i even rolled back to the old crux and i got the same issue, which is good because i think it means that something that's in my scene/project or that there's something wrong with the terrain itself which isn't giving any data to the TI script. I'm pretty sure there's something up with the terrain i'm using in the project.

    I do have multiple copies of the project with the old crux working good, I'll run through the tests over the other projects, worst come to worst i'll fall back on the old crux because it's working really well. :)

    Thanks for the fast response and for your help!
    I'll let you know if I find anything! :)
     
  24. KIR99

    KIR99

    Joined:
    Feb 21, 2017
    Posts:
    15
    Okay so i found out what was wrong in my scene! :)

    I've made the noob mistake of having the Y axis on my Crux object too far up (55f) where i assumed this object couldn't reach the terrain in order to get the info. I've just simply set the Crux object position on par with the Terrain's Y axis and it works perfectly haha
     
    Last edited: Jul 18, 2017
  25. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    Great to hear you were able to figure everything out!
     
  26. jrackley

    jrackley

    Joined:
    Jan 26, 2017
    Posts:
    14
    Can someone please explain to me how to set up the node based spawning? I am slightly confused on how this works, and any help would be appreciated,
    thanks in advance
     
  27. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    Hey there!

    There is nothing you need to do on your end with setting up nodes. All you have to do is specify the distance at which the objects are disabled.

    The node system simply spawns AI to nodes that are disabled when they are too far away from the player. This helps increase performance by keeping AI disabled until the player is closer to the AI.
     
    jrackley likes this.
  28. jrackley

    jrackley

    Joined:
    Jan 26, 2017
    Posts:
    14
    Thank you for the fast reply and explanation.
     
  29. Snownebula

    Snownebula

    Joined:
    Nov 29, 2013
    Posts:
    167
    Is anyone else getting errors in Unity3d Pro 5.6?
     
  30. Snownebula

    Snownebula

    Joined:
    Nov 29, 2013
    Posts:
    167
    How do I get this setup with Animals Full Pack, Crux, Emerald AI and MapMagic?
     
  31. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    Hey there!

    What errors are you getting? I'll get an update sent out asap if they are directly related to unity 5.6.

    It is worth noting that Emerald AI need to have a baked NavMesh in order to work with Map Magic. This can be done by pinning your Map Magic terrains so they can be baked.

    1) Start off by applying an Emerald component to your animals by going to Window>Emerald AI>Create AI on Seletect Object.

    2) Using the Emerald Editor, setup your AI's behaviors and settings. Ensure that you apply all needed animations in the Animation Options. If you're using Mecanim, make sure you create an Animator Controller through Emerald. You will need to manually setup the animations through the newly created Animator Controller.

    3) Once you've created your Emerald AI animals, save them as prefabs.

    4) In the Crux options, if you haven't already done so, create a biome. This biome will be defined by the textures you set for it. Use the textures from the terrains created with Map Magic.

    5) Once you've created a biome and assigned your textures for it, create a new Animal Object. This will open up a new option that will allow you to choose what object is spawned for this new animal object.

    6) Assign the prefab you created earlier to the said newly created animal object slot. Do this for as many animals you have.

    7) Set your additional spawning and animal specific settings you want set via the Crux Editor. With it, you can control if animals spawn as groups, how many if groups, spawn distances, population caps, and more.

    8) If you haven't already done so, bake your terrains created with Map Magic. This can be done by pinning your terrains so they become generated and visible then baking them using the Unity NavMesh bake tool. Make sure they are marked as Static in the gameobject's options in the upper right hand corner.

    If you run into any issues setting up, just let me know.
     
  32. Snownebula

    Snownebula

    Joined:
    Nov 29, 2013
    Posts:
    167
    "GetRemainingDistance" can only be called on an active agent that has been placed on a NavMesh.
    UnityEngine.AI.NavMeshAgent:get_remainingDistance()
    Emerald_Animal_AI:MainSystem() (at Assets/Emerald AI/Scripts/Emerald AI/Emerald_Animal_AI.cs:1490)
    Emerald_Animal_AI:Update() (at Assets/Emerald AI/Scripts/Emerald AI/Emerald_Animal_AI.cs:1850)


    "GetRemainingDistance" can only be called on an active agent that has been placed on a NavMesh.
    UnityEngine.AI.NavMeshAgent:get_remainingDistance()
    Emerald_Animal_AI:MainSystem() (at Assets/Emerald AI/Scripts/Emerald AI/Emerald_Animal_AI.cs:1518)
    Emerald_Animal_AI:Update() (at Assets/Emerald AI/Scripts/Emerald AI/Emerald_Animal_AI.cs:1850)
     
  33. Snownebula

    Snownebula

    Joined:
    Nov 29, 2013
    Posts:
    167
    How exactly do you bake procedurally created content?
     
  34. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    This error is happening because you need to bake your NavMesh. A tutorial can be found here: https://docs.unity3d.com/Manual/nav-BuildingNavMesh.html

    Baking Unity's NavMesh with procedural terrains should be possible with Unity's runtime NavMesh system. However, I haven't had the chance to throughly test it and it may still be in beta.
     
  35. Snownebula

    Snownebula

    Joined:
    Nov 29, 2013
    Posts:
    167
    I got it to work, the error was my fault. I added an AI thing to the game, I didn't relize it was there. Things spawn now. I look forward to using this. How do I get the AI to animate my animals from "Animals Full Pack"? Is there a video tutorial for this somewhere?
     
    Last edited: Sep 6, 2017
  36. Snownebula

    Snownebula

    Joined:
    Nov 29, 2013
    Posts:
    167
    This is one of the problems I have: [​IMG]

    I don't even see any compile errors :S

    This is what happens when you play: [​IMG]
     
    Last edited: Sep 6, 2017
  37. Snownebula

    Snownebula

    Joined:
    Nov 29, 2013
    Posts:
    167
    How do you "You will need to manually setup the animations through the newly created Animator Controller." I have never used this before. Can you point me to a tutorial for this?
     
  38. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    Hey there!

    I believe this can be fixed by opening the script and renaming the Class to CruxCharacterController

    If you don't know how to do this, I can send you the update script. I wasn't aware this was an issue. It happens because there it's the same script and as the Emerald character controller.

    When I get the chance tomorrow, I can make you a tutorial.
     
  39. Snownebula

    Snownebula

    Joined:
    Nov 29, 2013
    Posts:
    167
    OMG how did I overlook that before???

    Sweet I look forward to your tutorial. Thanks a ton! :D
     
  40. RAZD112

    RAZD112

    Joined:
    Aug 30, 2017
    Posts:
    70
    hey , i bought today Emerald and Crux
    i managed to deal with Emerald but Crux drives me crazy ...
    im doing everything as explained in the tut but it doesnt work nothing spawning and no errors !! and yes ive attached my player in the spawning options
     
  41. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    Hey there!

    Great, sorry to hear about you issue though. I'm sure we can figure what's going on. I'll need to ask a few questions to help me better understand what's going on.

    1) Did you apply textures to define your biomes? Are you using a Unity terrain?
    2) Did you create an object for your biome?
    3) Did you attach an object to the object slot?
    4) Are you global and object populations caps high enough?
    5) Did you adjust any of the Spawning Options?
    6) Are you using the object pool option?
    7) What version of Unity are you using?
     
  42. RAZD112

    RAZD112

    Joined:
    Aug 30, 2017
    Posts:
    70
    yes to 1-6
    and for 7 , unity 5.6.3f1
     
  43. RAZD112

    RAZD112

    Joined:
    Aug 30, 2017
    Posts:
    70
    upload_2017-9-11_19-46-9.png upload_2017-9-11_19-46-46.png
    upload_2017-9-11_19-47-9.png
    BOOM WORKS PERFECT ! THANKS BUT ONE LAST THING BEFORE THE SALE GOES OFF
    CAN YOU TELL ME IF IT WORKS WITH ULTIMATE SURVIVAL FOR SURE ? TY
     
    Last edited: Sep 11, 2017
  44. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    Great to hear!

    I'll be able to look more into it tomorrow, but it looks like UniStorm is working with Ultimate Survival. It did require editing some of the Ultimate Survival time of day script though. If you're interested, I'll be making a tutorial for adding support. It's a fairly simple process.
     
  45. RAZD112

    RAZD112

    Joined:
    Aug 30, 2017
    Posts:
    70
    ok , so if you saying i trust you ,
    ill buy it . in the worst case ill ask a refund from you lol:)) jk
     
  46. RAZD112

    RAZD112

    Joined:
    Aug 30, 2017
    Posts:
    70
    hey sorry for bothering ,
    ive another issue with crux
    i set the Y spawn point to 0
    and when im starting the game its immediately going off to -5 idk what to do help pls..
    btw the terrain height set to 0 also
     
  47. Ramulos

    Ramulos

    Joined:
    Feb 19, 2017
    Posts:
    20
    Hello

    I was wondering if there's been any updates on Crux mesh support. Any predicted release date? I've pushed off working on enemy spawn related things for about two months but now this update is quite needed. Without it crux is unusable for our project. I don't mean to sound bitter and I apologize if I do, I just need to know if I should look for another solution.
     
  48. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    You're totally fine.

    Strange, I'm not sure what would cause this. It's the first time I've heard of it. You can try one thing though. While having your Crux system selected, at the top of Unity go to GameObject>Break Prefab Instance. This may resolve your issue.



    Hey there!

    Mesh support is certainly something that's going to be added. Plan on the update being submitted within the next week or two. However, I'm not sure if texture detection will be possible initially as I don't think Unity has a way to detect the texture at a certain point when the mesh has multiple textures.
     
  49. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    214
    @BHS, So in this example I don't have NavMesh under this lake. Will Crux will be smart enough to not try to spawn enemies there?

    [​IMG]

    I already had problem when Crux spawned enemy in the air, because there was no navMesh under it.

    [​IMG]

    I was able to get around that problem by adjusting slope angle, but I'm afraid areas like this lake will constantly cause similar issue. If this is the case, then it will be awesome if you raycast against nav mesh. Before determining spawn point. I know, that it's possible because even Playmaker has that kind of action.

    [​IMG]
     
    Last edited: Sep 13, 2017
  50. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    2,973
    Hey there!

    As long as the textures from the lake are not included in the biome's textures, it will not spawn there. However, it doesn't detect if NavMesh is present. It is certainly something that can be added with the next update though. Unity has API to detect if NavMesh is present.

    For a temporary solution, this could be added to the AI, if they spawn on a portion of terrain that doesn't have NavMesh, it can be despawned and sent back to the object pool.

    I'll see if I can get something together sometime tomorrow.