Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

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

  1. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I didn't have time to fully test Unity 5.6 with Crux 2.0. During 2.0's development, I believe there was a reason for this do to some needed Unity API, but I will double check and add support for version 5.6 if I can.
     
    wood333 likes this.
  2. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I used to do this, but it lead to far too many issues with users using an outdated version that didn't reflect the improved versions. I will try to add a Unity 5.6 version for Crux 2.0.
     
  3. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I have Vegetation Studio Pro and I'm looking into adding support for it.
     
    attaway and GorkaChampion like this.
  4. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I don't see why it shouldn't work. I can look into this though.
     
  5. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    would be super super super appericated. running 2 versions of crux would be great. also, is it capable of doing runtime changes? such as deactivate and reactive in runtime, modify spawn list.
     
  6. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I agree having two systems would be beneficial. I'm not sure if it can be modified at runtime. I will take a look and get back to you regarding that. May I ask why you would want to modify it during runtime?
     
  7. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Crux 2.0.1 has been submitted and is awaiting approval.

    This update adds integrated support for Emerald AI. This allows Crux to automatically remove and adjust the population of an AI when it's killed and spawned using Crux
     
    GorkaChampion and SickaGames1 like this.
  8. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    For level updates, for example. In said biome, you spawn X creatures, but after a certain quest or time frame, the spawn changes. In the case im using it. I have little monster camps that can randomly spawn, when a camp is spawned it modifies the spawn of that biome, until the camp is destroyed. I made my own spawn system that does this, but i have issues with sometimes spawning not on navmesh. I used crux originally for the insipration of my own spawn system. But like i said i have 2 slots for each biome, that default to null, until a event camp is spawned close by, then those slots get filled by a corrisponding creature, such as giant spiders or goblins, bandits, ect. I suppose i could spawn a generic monster with crux, then script that object to convert itself into a different monster based on conditions.
     
  9. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    I also have “safe” zones, so if the players enter towns they are safe, easy to do with just setting up town biomes, but they also get a safe zone when they create a campfire out in the wilderness.
     
  10. spinaLcord

    spinaLcord

    Joined:
    May 25, 2015
    Posts:
    29
    @BHS

    hello its ok if i disable this query,without running in problems?

    !Physics.CheckSphere(m_PositionToSpawn, AILayerMaskDectectionDistance, AILayerMask)

    CruxSystem.cs Line:515

    Code (CSharp):
    1. if (UseLayerDetection == UseLayerDetectionEnum.Yes && Vector3.Distance(m_PlayerObject.position, m_PositionToSpawn) >= m_MinRadius /*&& !Physics.CheckSphere(m_PositionToSpawn, AILayerMaskDectectionDistance, AILayerMask)*/ ||
    2. Vector3.Distance(m_PlayerObject.position, m_PositionToSpawn) >= m_MinRadius && UseLayerDetection == UseLayerDetectionEnum.No)
    I understand what Physics.CheckSphere do, but i can't figure out what triggers it to True on my Project But It prevents objects to spawn currently in some case.
     
  11. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    is it possible to still get the older version of crux?

    Haha poor BHS, released an update for crux, emerald and soon unistorm all back to back, gotta be one of the most busy dev artists lol. Your gonna need a vacation
     
    Last edited: Mar 30, 2019
  12. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Alright, thanks for the details, that makes sense.

    So I tested modifying the biome spawnable objects during runtime and everything seems to work okay. Below is a simple example that modifies the first biome Wildlife objects to the ReplacementWildlifeObjects. This requires you to make one small modification to the CruxSystem script. Simply change the AssignRarityCategories to public. This allows the spawnable object lists to be reassigned when you modify them. I will make this function public with the next update.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Crux;
    5. using Crux.Utility;
    6.  
    7. public class ModifyBiomesDuringRuntime : MonoBehaviour {
    8.  
    9.     public List<CruxObject> ReplacementWildlifeObjects = new List<CruxObject>();
    10.  
    11.     void Update ()
    12.     {
    13.         if (Input.GetKeyDown(KeyCode.G))
    14.         {
    15.             CruxSystem.Instance.BiomeList[0].WildlifeObjects = ReplacementWildlifeObjects;
    16.             CruxSystem.Instance.AssignRarityCategories(); //You will need to go into the CruxSystem script and make this function public
    17.         }
    18.     }
    19. }
    20.  
     
    Syllvia and Weblox like this.
  13. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    All this does is search for other spaned objects of the appropriate layer to avoid them being spawned too close to each each other. If you don't want to use this feature, just disable Use Object Detection.
     
    spinaLcord likes this.
  14. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    It's no longer supported as the newer version is quite a bit better. May I ask why you would like the older version over the newer version?

    Yes, I certainly do. :)
     
    SickaGames1 likes this.
  15. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    For the duo systems older one worked fine with 2 crux systems running. I've built a playmaker version based off crux I'm using. I just don't have group spawning or individual population types. Which I can get working. I know your super busy and don't want to put u out. I was just hoping duo crux was gonna be a easy fix.
     
    Last edited: Mar 31, 2019
  16. spinaLcord

    spinaLcord

    Joined:
    May 25, 2015
    Posts:
    29
    ok this is good to know.
     
  17. wInevitable

    wInevitable

    Joined:
    Jan 9, 2018
    Posts:
    2
    Hi @BHS, I'm using Crux with Emerald AI.

    Overall really great experience (thank you!), but I'm running into one issue. My first set of objects spawn in fine with movement animations, sound and damage, but second and subsequent sets no longer animate their walk/run movements correctly (they float/glide above the ground).

    Occasionally, they will also no longer detect the Player. They still deal damage though and their attack animations/sounds work correctly. Not sure if this rooted in Crux or Emerald, but have you seen this before?
     
  18. wInevitable

    wInevitable

    Joined:
    Jan 9, 2018
    Posts:
    2
    I figured out the cause of the issue in my previous post, but am unsure of the proper solution. It looks like the new game objects spawned after the first round enter the "Combat Movement" path but are always in an "Idle" state. My quick fix was to swap out the combat idle animation for the run animation and now they appear to run, but I'm guessing there is something causing them to remain in an Idle state vs Walk/Run? Could this be related to their detection settings or an enter Idle state setting?
     
  19. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    251
    Any eta on a CTS 2019 fix? Thanks!
     
    prabhjotlamba likes this.
  20. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    So is it cts 2019 why I cant get crux to work?

    I've been using crux for a while and never had an issue but I do notice cts 2019 is different than the last time I used it
     
  21. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    In cts not stripping textures?
     
  22. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    I never use stripping textures. I've used normal cts with crux for awhile. Just recently upgraded cts to 2019 version and also upgraded crux to the latest version. It all worked before.
     
  23. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    I changed the terrain back to unity terrain and same issue is happening

    I also use vegetation studio pro and using unity 2018.3.14f1

    Has anyone else had any similar issues and have a fix?
     
  24. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    Also I just notice the feature to test height wasnt working for me either. I did right click and try a few things to make sure scene view was active
     
  25. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    So i have attempted it with normal unity terrain and mesh terrain also and neither spawns AI. Using unity 2018.3
     
  26. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    251
    Yeah I'm having the same mysterious issue. I may have to dive into the source myself soon if an update isn't forthcoming (assuming the source isn't compiled...)
     
  27. prabhjotlamba

    prabhjotlamba

    Joined:
    Jun 2, 2018
    Posts:
    6
    Facing problems with CTS 2019.
     
  28. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    @BHS, I've been recently monitoring performance issues with profiler. And noticed that Crux sometimes spawns more than 1 object at the time, which of course creates noticeable hiccup. Is there a way to prevent Crux from spawning more that 1 object in a single frame?

    p.s. Maybe not using group spawns is the way to do it?
     
  29. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Is that still a thing and do you have an ETA on a release?
     
  30. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    251
    Where is the author? No replies for months on this product...
     
  31. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    He is very active on his Emerald AI forums so maybe he's just not getting notifications for this forum. You can always post over there and see if you can get his attention.
     
  32. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Hey everyone,

    My apologies for the lack of support/communication on the Crux forum. For some reason I wasn't receiving notifications. I'm currently responding to all your posts.
     
  33. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Hey there,

    This sounds like an Emerald AI issue. This has been fixed with the version I'm currently working on releasing. It happens because the AI's states aren't properly reset when they are respawning. You can try to fix this yourself by calling EmeraldComponent.EmeraldBehaviorsComponent.DefaultState(); at the bottom of the ResetAI function within the EmeraldAIEventsManager script.
     
  34. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    CTS has worked for me in the past with stripping textures disabled. Maybe something has changed with the 2019 version. I will look into this and find out what's causing the issue.
     
  35. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    The height test as in the editor displaying the height of the current position of the mouse? In order for this feature to work correctly, you must set the layer of your terrain within the Crux editor. By default, the Default layer is not used for detection as it would pick up the height of other non-terrain objects. Setting your terrain to its own layer should allow it to work correctly.

    Can you please check to see if the Crux demo scenes are working correctly? If they are, something may be setup incorrectly within your scene and with Crux.
     
  36. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I'm currently looking into this.
     
  37. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    Yes, this would be group spawning feature. Not currently, but I will add spawning over the course of multiple frames with the next version.
     
    Gua likes this.
  38. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    After my Emerald AI update is finished, I will finish the Crux update.
     
    Willbkool_FPCS and Rowlan like this.
  39. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    251
    Welcome back!
     
  40. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    251
    So I reinstalled Crux to experiment. I don't have strip textures enabled, so yeah, it's not working. Using 2019.1.12f1 and CTS 2019. I almost dived into the source code myself to see if I could figure it out, but couldn't isolate the method that actually chooses where to spawn creatures. While we're at it, would be awesome if it would work with "Strip Textures" enabled as well :)

    If you're not aware, Procedural Worlds has a great Discord channel where Adam is quite helpful in, I bet he'd be happy to quickly zero in on what you need to tweak. True, CTS isn't YOUR product, but it is a very popular one and for myself a vital one. Really looking forward to a fix because my world feels a bit empty right now without my furry friends.
     
  41. ncho

    ncho

    Joined:
    Feb 1, 2014
    Posts:
    99
    Would Crux be helpful e. g. for incidental world details like spaceships or flocks of birds passing by or would I easier be served with manually scripting this?
     
  42. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    You can put a Y off set. So aslong as your things have some sort of AI, it should work. Ive used it for items along as npcs and loot
     
  43. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    @BHS I just picked up Crux, but am a bit disappointed because there is no Event system. I need to be able to have callbacks for OnSpawned at the very least. Are you planning to add an event system at some point?

    [EDIT]
    I've added in some code to call my OnSpawned function so this issue is not a blocker.
     
    Last edited: Sep 3, 2019
  44. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    @BHS I am getting an error like the following sometimes:

    Texture rectangle is out of bounds (514 + 1 > 512)
    UnityEngine.TerrainData:GetAlphamaps(Int32, Int32, Int32, Int32)
    Crux.Utility.TerrainInfo:GetTextureBlend(Vector3) (at Assets/Crux - Procedural AI Spawner/Scripts/System/TerrainInfo.cs:87)
    Crux.Utility.TerrainInfo:GetDominateTexture(Vector3) (at Assets/Crux - Procedural AI Spawner/Scripts/System/TerrainInfo.cs:102)
    Crux.Utility.TerrainInfo:UpdateTerrainInfo() (at Assets/Crux - Procedural AI Spawner/Scripts/System/TerrainInfo.cs:50)
    Crux.CruxSystem:Create() (at Assets/Crux - Procedural AI Spawner/Scripts/System/CruxSystem.cs:497)
    Crux.<InitializeCrux>c__Iterator1:MoveNext() (at Assets/Crux - Procedural AI Spawner/Scripts/System/CruxSystem.cs:337)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    Crux.CruxSystem:Start() (at Assets/Crux - Procedural AI Spawner/Scripts/System/CruxSystem.cs:268)

    I debugged it and when it generated the above error, the Pos for the GetDominateTexture function was

    301.5, 13.3, 52.7

    The terrain size is 300x300.
     
  45. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I'll be adding events when I get the next Crux update out. Right now, my focus is getting Emerald AI 2.3 submitted which should happen by the end of this week. After that, I'll get the Crux update finished.

    Strange, I'll looking into this to see what's going on. What version of Unity are you using?
     
  46. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    2017.1.5f1
     
  47. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Hi I setup Emerald AI characters and saved them as prefab objects then added each to a Crux Biome and they were working great.

    Today, they just wont spawn and all I have done is work on some sound effects for another separate object. any ideas where to start looking. I have checked the Layers and gone through everything but cant find a solution.

    Any ideas appreciated, thanks
     
  48. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    I actually got crux to work agaion but then it just stopped working again using unity 2019.2.9

    This is the error it spits out: Any suggestions to get it working appreciated thanks.

    IndexOutOfRangeException: Index was outside the bounds of the array.
    Crux.CruxSystem.Create () (at Assets/Crux - Procedural AI Spawner/Scripts/System/CruxSystem.cs:518)
    Crux.CruxSystem+<InitializeCrux>d__69.MoveNext () (at Assets/Crux - Procedural AI Spawner/Scripts/System/CruxSystem.cs:337)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    Crux.CruxSystem:Start() (at Assets/Crux - Procedural AI Spawner/Scripts/System/CruxSystem.cs:268)
     
  49. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515

    try with a flat plain terrain. see if it works. i've found issues using custom created terrain especially gaia. switching to a flat terrain and making sure my height for spawn was set right, they normally always spawned
     
    Hawk0077 likes this.
  50. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Thanks, much appreciated. I actually got it going. Thats twice I made a simple mistake that stopped the spawning and so I spent time trying to fix it.

    I appreciate the efforts though, thanks