Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

Unity AI Planner version 0.2.4 released

Discussion in 'AI & Navigation Previews' started by TrevorUnity, Nov 5, 2020.

  1. TrevorUnity

    TrevorUnity

    Unity Technologies

    Joined:
    Jun 28, 2017
    Posts:
    101
    Hello, everyone! Today we are releasing the Unity AI Planner version 0.2.4. In the past few months, our team has moved the trait language into its own package, Semantic Traits. With this change, we taking the first steps in enabling the integration of the trait language into other gameplay and authoring tools for Unity. The Unity AI Planner will continue to use traits, becoming the first of a suite of decision-making and agent control packages built on top of Traits. Highlights in this release:
    • Minimum Unity version is now 2020.1.2f
    • Entities dependency updated to version 0.16.0-preview.21
    • Support for list operators in ActionDefinitions
    • Added a "PlanningAgent" trait in planning states as a flag to identify the object representing the agent ("self")
    • Text searching for state data in the plan visualizer
    • Planning jobs now allocate less temporary memory during execution
    • State conversions after world queries now allocate less managed memory
    • A new, experimental C# API has been made public, allowing for customized use of the planner modules
    Sample projects: https://github.com/Unity-Technologies/ai-planner-samples
    Full docs: https://docs.unity3d.com/Packages/com.unity.ai.planner@0.2/manual/index.html


    Adding the AI Planner to your project
    As you may know, beginning with Unity 2020.1, preview and experimental packages are no longer discoverable in the package manager. See here and here for more information. You will still be able to try out the latest releases of the AI Planner, but to do so, follow either of the methods for adding the package below:

    Method 1:

    In the package manager window, select the plus (+) sign at the top of the package list, then choose the option "Add package from git URL...", entering "com.unity.ai.planner" as input. After a few seconds, the package will be downloaded and imported into your project.

    upload_2020-11-4_16-17-29.png

    upload_2020-11-4_16-17-55.png

    Method 2:

    Add this line to your manifest file of your project's "Packages" directory:


    "dependencies": {
    "com.unity.ai.planner": "0.2.4-preview.3",
    ...



    What's next for the AI Planner?

    Since September, our team has been taking a short hiatus from development on this package so that we may lend our time to the NavMesh team, to help improve stability and reduce user pain. Currently, we expect this effort to round out the remainder of 2020. In the meantime, we are laying out the future plans and feature roadmaps for next year. For 2021, we will focus on integrating the packages with other gameplay and authoring tools at Unity. Stay tuned!
     
    Last edited: Jan 23, 2021
  2. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    152
    bad luck with new version, throws me a "ObjectDisposedException: The Unity.Entities.EntityManager has been deallocated, it is not allowed to access it" error, seems related to semanticObject conversion issue?
     
    vx4 likes this.
  3. TrevorUnity

    TrevorUnity

    Unity Technologies

    Joined:
    Jun 28, 2017
    Posts:
    101
    Can you give us some context as to what you tried to do?
     
  4. santadiego

    santadiego

    Joined:
    Aug 31, 2014
    Posts:
    26
    using Unity.Semantic.Traits; // no such lib?

    var traitComponent = other.gameObject.GetComponent<TraitComponent>();

    should be changed to I think
    var traitComponent = other.gameObject.GetComponent<SemanticObject>();

    am I wrong? where is the namespace for this?

    Namespace Unity.Semantic.Traits is missing?
    solved.. must be added to assembly defs, but you cant pick it from the dropdown so I assumed that was not right.. you must dragndrop to add to assembly
     
    Last edited: Nov 6, 2020
    TrevorUnity likes this.
  5. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    152
    just import AI.planner , and then add a trait on a gameobject, then play, nothing more. (2020.2.0b08)
    during my test, also got some weird stuff like "operands compile error" ( can't remember full err info) or cycling compile when click play button (then editor goes to crash)
     
    vx4 likes this.
  6. TrevorUnity

    TrevorUnity

    Unity Technologies

    Joined:
    Jun 28, 2017
    Posts:
    101
    Ah. We haven't tested on 2020.2 extensively. I'll look into it.
     
  7. vx4

    vx4

    Joined:
    Dec 11, 2012
    Posts:
    132
    i try to do simple test in unity(2020.2 b10)
    the following error show :

    Semantic Build:
    Temp\PlannerAssembly\Generated.AI.Planner.Plans\NewProblemDefinition\PlannerSystemsProvider.cs(18,113): error CS0246: The type or namespace name 'DefaultHeuristic' could not be found (are you missing a using directive or an assembly reference?)
    UnityEditor.EditorApplication:Internal_CallDelayFunctions ()

    Assembly build finished for Temp\PlannerAssembly\Generated.AI.Planner.Plans.dll -- Warnings: 0 - Errors: 1
    UnityEditor.EditorApplication:Internal_CallDelayFunctions ()


    Planner Build:

    Temp\PlannerAssembly\Generated.AI.Planner.Plans\NewProblemDefinition\PlannerSystemsProvider.cs(18,113): error CS0246: The type or namespace name 'DefaultHeuristic' could not be found (are you missing a using directive or an assembly reference?)
    UnityEditor.AI.Planner.CodeGen.PlannerAssemblyBuilder:Build () (at Library/PackageCache/com.unity.ai.planner@0.2.4-preview.2/Editor/CodeGen/PlannerAssemblyBuilder.cs:149)

    Assembly build finished for Temp\PlannerAssembly\Generated.AI.Planner.Plans.dll -- Warnings: 0 - Errors: 1
    UnityEditor.AI.Planner.CodeGen.PlannerAssemblyBuilder:Build () (at Library/PackageCache/com.unity.ai.planner@0.2.4-preview.2/Editor/CodeGen/PlannerAssemblyBuilder.cs:149)


    When Enter play mode:
    Planner systems provider not found. Have you generated the code (AI->Planner->Build)?
    UnityEngine.Debug:LogError (object)
    Unity.AI.Planner.Controller.DecisionController:Initialize () (at Library/PackageCache/com.unity.ai.planner@0.2.4-preview.2/Runtime/Controller/DecisionController.cs:176)
    Unity.AI.Planner.Controller.DecisionController/<Start>d__53:MoveNext () (at Library/PackageCache/com.unity.ai.planner@0.2.4-preview.2/Runtime/Controller/DecisionController.cs:284)
    UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)

    Decision Controller for object GameObject has not been initialized.
    UnityEngine.Debug:LogWarning (object)
    Unity.AI.Planner.Controller.DecisionController/<Start>d__53:MoveNext () (at Library/PackageCache/com.unity.ai.planner@0.2.4-preview.2/Runtime/Controller/DecisionController.cs:287)
    UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)
     
  8. TrevorUnity

    TrevorUnity

    Unity Technologies

    Joined:
    Jun 28, 2017
    Posts:
    101
    We also discovered this error late last week. We'll be releasing a fix soon.
     
    vx4 likes this.
  9. TrevorUnity

    TrevorUnity

    Unity Technologies

    Joined:
    Jun 28, 2017
    Posts:
    101
    0.2.4-preview.3 is out. It contains a fix.
     
    Djayp and vx4 like this.
  10. vx4

    vx4

    Joined:
    Dec 11, 2012
    Posts:
    132
    it works.
     
  11. DrBoum

    DrBoum

    Joined:
    Apr 19, 2020
    Posts:
    12
    hi @TrevorUnity , there is an issue currently with the AIplanner(0.2.4) and the Enter Play mode Settings => Enter Play mode option(Experimental)(Unity 2020.1.4f1).
    The way you are currently using the EntityManager doesn't work if that settings is enabled
    bug occurs when i press play upload_2020-11-18_21-7-8.png
    basically every trait in my scene throws this exception.
    in order to reproduce all you need to do is the following:
    1. create a new project
    2. add aiPlanner
    3. create a trait definition
    4. create an action definition using that trait
    5. create a problem definition using the action
    6. build semantic
    7. build AI
    8. check the Enter Play mode Settings => Enter Play mode option(Experimental) in the project settings with reload domain and scene uncheck which was recomended by Joachim Ante on his post
    9. press play
    this play mode experimental settings is a real time saver i hope you can fix it
     

    Attached Files:

    Last edited: Nov 20, 2020
  12. vx4

    vx4

    Joined:
    Dec 11, 2012
    Posts:
    132
    Dears,
    Is there update regards sample projects.
     
    DrBoum likes this.
  13. DrBoum

    DrBoum

    Joined:
    Apr 19, 2020
    Posts:
    12
    Yes please ! we want more info about the planner !
     
  14. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    182
    ETA for samples update? I want to start learning ai planner
     
  15. xzp_xzp

    xzp_xzp

    Joined:
    Jun 4, 2019
    Posts:
    5
    The Location Moveable Navigate Is Old in 0.2.4.Preiview.3 Editor model.

    And report some errors about Memory leak when end play.
     
    Last edited: Dec 16, 2020
  16. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    364
    Could you provide some information as to what tools are being considered here?
    :)
     
    vx4 likes this.
  17. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    235
    Last edited: Dec 18, 2020
    vx4 likes this.
  18. Labecki

    Labecki

    Joined:
    Apr 14, 2015
    Posts:
    17
    I have been experiencing a null reference exception when trying AI -> Build:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEditor.AI.Planner.CodeGen.CodeGenerator.IsListType (System.Type type) (at Library/PackageCache/com.unity.ai.planner@0.2.4-preview.3/Editor/CodeGen/CodeGenerator.cs:616)
    3. UnityEditor.AI.Planner.CodeGen.CodeGenerator+<>c__DisplayClass11_0.<GenerateAction>b__3 (Unity.AI.Planner.Traits.Operation p) (at Library/PackageCache/com.unity.ai.planner@0.2.4-preview.3/Editor/CodeGen/CodeGenerator.cs:299)
    4. System.Linq.Enumerable+WhereSelectListIterator`2[TSource,TResult].ToList () (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
    5. System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
    6. UnityEditor.AI.Planner.CodeGen.CodeGenerator.GenerateAction (Unity.AI.Planner.Traits.ActionDefinition action, System.String planName, System.Type[] customTypes, System.String outputPath, System.Boolean includeEnums) (at Library/PackageCache/com.unity.ai.planner@0.2.4-preview.3/Editor/CodeGen/CodeGenerator.cs:354)
    Any idea why this might be occuring?

    I also have two additional questions:

    (1) I am planning on using this for a turn-based game rather than real time. Is it possible to use the AI planner in this sort of context? I.e. permitting the AI to only execute one step of a plan each turn?

    (2) It is possible to write methods that will alter the traits of semantic objects when the human player takes actions?
     
    Last edited: Dec 29, 2020
  19. vx4

    vx4

    Joined:
    Dec 11, 2012
    Posts:
    132
  20. TrevorUnity

    TrevorUnity

    Unity Technologies

    Joined:
    Jun 28, 2017
    Posts:
    101
    Haneferd, Djayp and vx4 like this.
  21. TrevorUnity

    TrevorUnity

    Unity Technologies

    Joined:
    Jun 28, 2017
    Posts:
    101
    It seems the issue stems from the generated traits code, from the new Semantic Traits package. I'll see about getting that package updated soon and report back when it is out.
     
    DrBoum and vx4 like this.
  22. dannymcgee

    dannymcgee

    Joined:
    Aug 5, 2015
    Posts:
    5
    Hey Trevor, I'm having some issues getting the "Tactics" sample working — is that still a WIP or does it need extra work to update?
     
    vx4 likes this.
  23. TrevorUnity

    TrevorUnity

    Unity Technologies

    Joined:
    Jun 28, 2017
    Posts:
    101
    It should be up-to-date, but perhaps I missed something last week. What issues are you facing?
     
    vx4 likes this.
  24. dannymcgee

    dannymcgee

    Joined:
    Aug 5, 2015
    Posts:
    5
    Thanks for the quick response!

    When I open the "Cover" scene and press Play, I'm seeing a NullReferenceException with this stack trace:

    Code (csharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Unity.Semantic.Traits.Queries.QueryConditionalGroup.ConvertTraitCollectionToTypes (Unity.Semantic.Traits.TraitCollection collection) (at Library/PackageCache/com.unity.semantic.traits@0.2.8-preview/Runtime/Unity.Semantic.Traits.Queries/TraitBasedObjectQuery.cs:64)
    3. Unity.Semantic.Traits.Queries.QueryConditionalGroup.Initialize () (at Library/PackageCache/com.unity.semantic.traits@0.2.8-preview/Runtime/Unity.Semantic.Traits.Queries/TraitBasedObjectQuery.cs:46)
    4. Unity.Semantic.Traits.Queries.SemanticQuery.Awake () (at Library/PackageCache/com.unity.semantic.traits@0.2.8-preview/Runtime/Unity.Semantic.Traits.Queries/SemanticQuery.cs:34)
    5. UnityEngine.Object:Instantiate(GameObject)
    6. <PlayScenarioSequence>d__13:MoveNext() (at Assets/Scripts/GameScenario.cs:176)
    7. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
    And immediately after that, an ArgumentException:
    Code (csharp):
    1.  
    2. ArgumentException: A component with type:CoverData has not been added to the entity.
    3. Unity.Entities.EntityComponentStore.AssertEntityHasComponent (Unity.Entities.Entity entity, Unity.Entities.ComponentType componentType) (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/EntityComponentStoreDebug.cs:280)
    4. Unity.Entities.EntityComponentStore.AssertEntityHasComponent (Unity.Entities.Entity entity, System.Int32 componentType) (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/EntityComponentStoreDebug.cs:286)
    5. Unity.Entities.EntityDataAccess.GetComponentData[T] (Unity.Entities.Entity entity) (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/EntityDataAccess.cs:778)
    6. Unity.Entities.EntityManager.GetComponentData[T] (Unity.Entities.Entity entity) (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/EntityManagerAccessComponentData.cs:36)
    7. CustomQuery.CoverDirectionFilter.Validate (Unity.Entities.EntityManager entityManager, Unity.Collections.NativeArray`1[T] entities, Unity.Collections.LowLevel.Unsafe.UnsafeBitArray entitiesValid) (at Assets/Scripts/CoverDirectionFilter.cs:26)
    8. Unity.Semantic.Traits.Queries.QueryConditionalGroup.Validate (Unity.Entities.EntityManager entityManager, Unity.Collections.NativeArray`1[T] entities, Unity.Collections.LowLevel.Unsafe.UnsafeBitArray entitiesValid) (at Library/PackageCache/com.unity.semantic.traits@0.2.8-preview/Runtime/Unity.Semantic.Traits.Queries/TraitBasedObjectQuery.cs:93)
    9. Unity.Semantic.Traits.Queries.TraitBasedObjectQuery.Validate (Unity.Entities.EntityManager entityManager, Unity.Collections.NativeArray`1[T] entities, System.Action`2[T1,T2] validCallback) (at Library/PackageCache/com.unity.semantic.traits@0.2.8-preview/Runtime/Unity.Semantic.Traits.Queries/TraitBasedObjectQuery.cs:186)
    10. Unity.Semantic.Traits.Queries.SemanticQuery.GetSemanticObjects () (at Library/PackageCache/com.unity.semantic.traits@0.2.8-preview/Runtime/Unity.Semantic.Traits.Queries/SemanticQuery.cs:53)
    11. Unity.AI.Planner.Controller.DecisionController.GetTraitBasedObjects () (at Library/PackageCache/com.unity.ai.planner@0.3.0-preview.2/Runtime/Controller/DecisionController.cs:327)
    12. Unity.AI.Planner.Controller.DecisionController.CreateNewStateFromWorldQuery () (at Library/PackageCache/com.unity.ai.planner@0.3.0-preview.2/Runtime/Controller/DecisionController.cs:372)
    13. Unity.AI.Planner.Controller.DecisionController.Initialize () (at Library/PackageCache/com.unity.ai.planner@0.3.0-preview.2/Runtime/Controller/DecisionController.cs:192)
    14. GameScenario+<PlayScenarioSequence>d__13.MoveNext () (at Assets/Scripts/GameScenario.cs:182)
    15. UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <bad59441812943c7b8d5a5ba85795810>:0)
    And then immediately after that, a warning about a likely memory leak.

    When I open the solution in Rider, I get 39 errors from various files, all related to not being able to resolve the symbol "Location". I tried running AI > Planner > Build and Semantic > Traits > Build just in case, but that didn't seem to fix it. I also tried re-cloning the repo from scratch just now (I had previously just pulled the latest changes to an old copy I already had), but no dice. The other three projects are working as expected though.

    EDIT: Forgot to mention I'm loading the project in v2020.1.17f1
     
  25. vx4

    vx4

    Joined:
    Dec 11, 2012
    Posts:
    132
    Same issue.
     
  26. TrevorUnity

    TrevorUnity

    Unity Technologies

    Joined:
    Jun 28, 2017
    Posts:
    101
    @dannymcgee @vx4

    It seems the world query on the prefabs had some invalid serialized data. I just pushed a fix.
     
    dannymcgee and vx4 like this.
  27. vx4

    vx4

    Joined:
    Dec 11, 2012
    Posts:
    132
    thanks
     
  28. xzp_xzp

    xzp_xzp

    Joined:
    Jun 4, 2019
    Posts:
    5
    @TrevorUnity
    I found that aiplanner may be random, which is not in most cases, unless you can specify a random seed each time randomly. This can be done to synchronize the frame between different machines.
    And Semantic Quert extra function can not use in unity 2020.2.7fc1 or 2020.3.0fc1 ;
    Another Why not use Gpu to compute In AIPlanner?Will the performance be better if you use gpu?I test robot 25, dirt 25 in one room.It need 60ms every frame in my computer(intel i7-7700HQ 2.8Ghz).It doesn't feel good in game.
     
    Last edited: Mar 12, 2021
  29. victor_apihtin

    victor_apihtin

    Joined:
    Mar 2, 2021
    Posts:
    21
    Would be nice if readme to samples repo was updated?
    It says it requires 2019.3, and an extra project is added (with no readme how to control it)
     
  30. victor_apihtin

    victor_apihtin

    Joined:
    Mar 2, 2021
    Posts:
    21
    I haven't yet looked through it all, but as far as I understand this is not a GOAP planner. This is just basically mimicking behaviour trees. Are there plans to make it into a more complex planner, where an action is broken down to smaller actions in a F.E.A.R. like model?
     
    Ruchir and vx4 like this.
  31. dannymcgee

    dannymcgee

    Joined:
    Aug 5, 2015
    Posts:
    5
    It is definitely not behavior trees. Agents are given goals and actions, each with a set of preconditions and effects, and based on their perception of the current world state they attempt to plan a sequence of actions which will achieve their active goal. That's basically textbook GOAP, though I believe this package has (and/or has planned) some extra features that add on to the classic GOAP formula. Behavior trees as I understand them are just a more intuitive way of modeling finite state machines, which is a completely different paradigm.

    It sounds like you're thinking of hierarchical task networks? I could be wrong (or misunderstanding you). (Either way I don't have enough info to answer your question, so sorry for the pointless notification. :p)
     
  32. dannymcgee

    dannymcgee

    Joined:
    Aug 5, 2015
    Posts:
    5
    @TrevorUnity I know it probably doesn't mean much coming from one dude with little to no activity on here, but given Unity's new "Do less and do it better" mandate, I just wanted to drop a note, for whatever it's worth, that I'm insanely excited about this package. I think it would be a massive value-add for Unity despite the relatively little buzz it seems to be getting, and I really hope they see it through to the finish line.
     
  33. victor_apihtin

    victor_apihtin

    Joined:
    Mar 2, 2021
    Posts:
    21
    @dannymcgee I judged only from the "tactics" sample and saw only "If-else" behavuor structure in it, therefore I said it looks like behaviour trees to me. After writing the message I then opened "Escape Room" and found an actual GOAP planner there :)
    And it is also fair enough that the same AI planner is in "Tactics", it's just that the actions list looks like a priority list, and it isn't.

    But yeah, I still wish tha package had sub-actions implemented and hope it is coming soon. Unless it is there, and I am not seeing it again :D
     
    Last edited: Apr 4, 2021
  34. drmgmt

    drmgmt

    Joined:
    Feb 19, 2020
    Posts:
    1
    Hi Everyone, I agree with DannyMcgee. I'm very excited for this package as well. I hope unity keeps it as part of their long term plans.

    @TrevorUnity I'm using Unity 2020.3f.3f1 I'm having trouble with Semantic Queries. There appears to be an issue with creating radius or specific object based filters. No error message but they just don't show up. Could this be related to the serialization fix you mentioned earlier? I can try to provide any other related details if requested.

    Is it possible to create a semantic query through implementing an interface in c# code?

    Thanks Trevor!
     
    Last edited: Apr 22, 2021
    vx4 likes this.
  35. dlewissandy

    dlewissandy

    Joined:
    Tuesday
    Posts:
    1
    In the video for the AI planner, they mention "macro actions" as a way to reduce the state space. How can I create a macro action in the current version of the AI planner?
     
unityunity