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.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

[RELEASED] RVSmartAI - node based utility AI framework with runtime editing and prefabs support!

Discussion in 'Assets and Asset Store' started by Roni92pl, Oct 22, 2019.

  1. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395











    RV SmartAI is a lightweight, flexible and high-performance utility AI framework.
    With SmartAI you’ll be able to visually model complex AI behaviours for your game with ease.

    It can be integrated into any project, regardless of stage, as it doesn’t force you to refactor all of your existing AI code, and can easily coexist and support your already implemented AI logic. Transfer only what you want of your game’s logic to SmartAI! For example you can leave your AIs movement logic untouched, and implement just your fighting logic, or even only target selection logic via AI graphs.

    SmartAI is the only graph-based utility AI solution on the asset store that fully supports prefab workflows in AI design process: create reusable graphs, nodes and even single graph elements, using Unity’s powerful prefab variants and property overrides.
    Full runtime editing support makes fine-tuning values for utilities so much faster and easier, as you have real time feedback on how changes you're making affects your AI behaviour.

    One of the biggest advantage of utility AI concept over FSMs or behaviour trees is that it’s much more scalable in terms of complexity while remaining simple and easy to maintain, understand decision process and debug.

    Included modules
    • RV Smart AI
      main module responsible for AI, node based editor

    • RV Load Balancing
      spreads work for multiple AI agents over many frames so you won’t have those nasty spikes in profiler

    • RV Logger
      simple tool to easily control debugging levels in your classes

    • RV Utilities
      general utilities/helper classes
    Note that all these modules are independent from main RV Smart AI module so they’re very useful for other stuff too, even not related to AI!
    There are also many ready to use AI examples wrote with flexibility in mind using interfaces, so you’ll be able to easily use them as base for your game and modify them.

    Features
    ► Visual node graph editor - write your AI behaviours in C# and play with them like legos
    ► As easy to use as behaviour trees while being much more scalable in terms of complexity
    ► Easily integrated into existing projects, regardless of stage
    ► Doesn’t force you to refactor all of your existing logic, only parts you want to
    ► User friendly and easy to use
    ► High performance and load balanced
    ► Runtime visual debugging
    ► C# source for all modules!
    ► Runtime graph modifications - see changes in your AI behaviours in real time and save a lot of time tweaking values
    ► Fully supports Unity prefab system - including nesting, variants and property overrides for graphs and all graph elements
    ► Unity’s undo system support
    ► Core system has no runtime allocations after initialization
    ► Written with flexibility and scalability in mind, as separate modules
    ► Many independent modules included in package
    ► Can be made to run on own threads (core system doesn’t use Unity API)
    ► Lot of script templates and base classes for common usages
    ► No subscription, no seats limits, buy once and use freely
    ► Responsive support via Discord and Unity forums

    Create reusable graphs, nodes and even single elements of nodes for the best workflow experience!

    You often need many graphs that are virtually the same with only one value change or one element added for different npcs in your game.
    Normally you would need to maintain all of them to make sure they stay in sync when updating them, but not with SmartAI!
    Create one base graph like you would normally and then make variants of them using standard Unity prefab workflows. This way you can have graphs with variety of difficulty levels, different tactics etc. while still basing on the same base graph... possibilities are endless!

    Graphs are prefabs by default, you can create variants of graphs and also all elements of graph can be made prefab, nesting and overrides are also supported.
    When you change value of some property of prefabed graph element you can use normal Unity override menu on that property to apply it to prefab or to revert:


    Working with prefabed graphs is basically the same as working with every other Unity prefab, so if you’re familiar with prefab workflows in Unity, you will feel at home working with SmartAI graph prefabs.
    If not - no problem, prefabing is not necessary or forced in any way and you can still use graphs just like any other asset files and don’t bother with prefabing.

    Let’s take a look at how prefabed graphs looks like in practice:


    As you can see, prefabed graph elements are marked with blue font.
    In second node(lower one) we have nested prefab. Node itself is prefab, and it has one utility that is also a prefab.
    You can make prefab from any graph element directly in graph window and also unpack them, all without even leaving graph window, using context menu on nodes.

    Join our Discord support server to discuss RVSmartAI, utility ai, or any other Unity development topic!
    https://discord.gg/b5J2DRR

    Thanks for reading
    Ronis Vision
     
    Last edited: Jun 3, 2020
    Rich_A, z3nth10n, zyzyx and 1 other person like this.
  2. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    1.1 Update!
    -Unity 2019 support
    -updated modules: new api for managing load balancing; now you don't need to have 'SmartAIUpdater' object on scene
    -update frequency can be set separately for every ai thanks to new load balancing api
    -general code cleanup and improved encapsulation in provided examples

    This update is mostly about LoadBalancing module update which provides simple, yet very powerful api to manage any method calls in your project.
    You register your method to load balancing system via Register method, when you want this method to be called regularly with some frequency.

    Lets take a look at some code
    Code (CSharp):
    1. LoadBalancerSingleton.Instance.Register(this, Tick, updateFrequency);
    First argument is object-owner that register this method. It isn't really used by system, it's more for organization and debugging, so you can see what objects registered what methods.
    Second one is your actual method you want to be called, with float argument for delta time - in some cases it's useful, and doesn't hurt if you don't need it.
    Third argument is actual call frequency, in hz - meaning how many times per second this method should be called, so if you pass 1 here, this method will be called once every second.

    Unregistering is even simpler:
    Overload when you want to unregister only one method
    Code (CSharp):
    1. public void Unregister(object _object, Action<float> _action)
    And overload when you want to unregister all methods registered by your object
    Code (CSharp):
    1. public void Unregister(object _object)
    All methods registered to this system will be automatically load balanced, meaning they won't be called all at once in one frame, but spread across many frames.
    It can be great replacement for 'manager' objects and even Unity's Update method in Monobehaviours:
    it's much faster to call, because it isn't called from unmanaged C++ engine layer like Monobehabiours are, and you have better control over then you want those method to be called - for example you may want your method to be called even if gameObject is disabled.
    To have behaviour like Unity Update method you just put Register method in OnEnable, and Unregister in OnDisable. Just make sure if LoadBalancerSingleton.Instance isn't null in OnDisable, since you don't know if it won't be destroyed first.
     
    Last edited: Oct 28, 2019
  3. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    906
    wow look strong
     
  4. LeeEonU

    LeeEonU

    Joined:
    Aug 18, 2015
    Posts:
    1
    Do you have document or sample scenes?
     
    f1chris likes this.
  5. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Yes, I sent you link to online documentation. There are few example scenes with simple behaviours provided like flee, follower, patrol.
     
  6. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    Look good but I'll need to see it in action first. Some videos and/or demos please ? !!!
     
    Last edited: Nov 25, 2019
    jeromeWork likes this.
  7. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    258
    @Roni92pl Is this suitable for 2D Card games AI such as Rummy and Poker?
     
  8. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    338
    Good to see more Utility AI assets, and great to see one with nodes/visual workflow. I'll definitely be checking this out for my next project.
     
  9. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    412
    videos / demos / tutorials are needed please.
    I've bought too many AI assets on a whim, only to be disappointed later. Looks interesting but there's very little information about how it actually works and how to use it.
    Says, "User friendly and easy to use"... can you show us some examples?
     
    Rich_A and f1chris like this.
  10. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Working on it :)
     
    jeromeWork and f1chris like this.
  11. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,744
    this is cool, show me a village sim, that's what you made this for right?
     
    f1chris likes this.
  12. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    Why don't you just show us short videos of those working screens ? We can figure how good the AI is with blue cubes, we don't need the full blown character animations.

    You can then keep working on a more elaborated trailer if you want to but at least we'll see it in action.

     
    laurentlavigne likes this.
  13. thatscraigz

    thatscraigz

    Joined:
    Mar 27, 2015
    Posts:
    88
    Hi there! The tool looks awesome :D

    I use PlayMaker currently for a lot of AI logic as well as actual interactions (attacking etc). Would there be an easy way to hook in PlayMaker with a system like this?

    best,
    craigz
     
  14. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Thanks! I've never used PlayMaker before, but I can see it is visual scripting tool.
    You see SmartAI is a framework, there are visual elements in graph, so that may seem confusing, but those elements are just scripts you write to use in SmartAI, so you can hook any third party you want as long as you can write some code :) Like I mentioned in features, 'actions' you have coded for your AI don't even have to be changed much to use it with SmartAi, just extract them to separate classes and inherit from AiTask, and then you can use them as 'legos' in graphs.

    Haha, I'd love to! ;)
    But honestly I started this project just because I was fascinated with utility ai and wanted to have my take on it for quite some time... but it grew to quite serious project and I realised it could be make into product, so others can benefit from it. Cheers.
     
  15. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    I've made some presentation using follower example
     
    Last edited: Dec 21, 2019
    f1chris likes this.
  16. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    338
    You need to reupload that at 1080p, its way too hard to see the UI at 720p.
     
  17. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Yeah, after your post I checked video on YT and it's more blurry than file I uploaded, yt compression I guess.
    Re-rendered it in higher res with better quality and uploaded, should be much better now;
    updated post with video.
     
  18. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,744
    one click smart follow - I could get used to that. how does it scale to say 1000 agents? it spits out entity burst c# code ? :D
    wait hang on a second, is this a potential field navigation I'm seeing?
     
  19. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Scales pretty good imo, with 1k agents wandering(moving from random place to other random place with destination blocking) takes about 0.3ms~ - you can see it in screenshot in first post. It's not using burst, and it doesn't need to;
    it's good old load balancing; btw logic on own thread + good load balancing and high lvl optimisation, and you don't need burst and all that ecs fuss.
     
  20. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,744
    Updated every frame or staggered?
     
  21. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    You can set for every ai tick frequency, usually 1-3hz is fine, so if you got 1hz set for agents and you got 100 agents, only one agent will be updated every frame (more or less), or in other words it will update every agent once in timespan of 1 second.
     
  22. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,744
    so you're getting 10k agents at 1hz
     
  23. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    If you're asking about performance screenshot, it's 1k agents at 1 or 2hz, can't remember exactly;
    The point is, overhead of the framework itself is so small that it's almost negligible, it's about what you make ai do in those tasks and scorers that will mostly affect performance.
     
    laurentlavigne likes this.
  24. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395

    Example battle scene for RPG pack - RVSmartAi addon package im working on.
    The Ai will wander around selected area or randomly if it's not assigned, and will attack any enemy it see by running towards it. There is also relationship system, so for each group you can set towards which groups they are hostile.
    It selects it's target based on it's hp and distance to itself, and most importantly it will flee if he's feeling intimidated - it takes into account nearby allies, nearby enemies and their strength, own health status and courage value to assess his situation - so you can often see whole groups retreating, which is nice.
    You can clearly see this in action in video at 0:46, where small group of red warriors are chasing one blue warrior, but they suddenly start to flee when even bigger group of blue warriors are coming :)
    And this is how graph for such Ai looks like
     
    Last edited: Jan 7, 2020
    RatherGood likes this.
  25. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Hello, SmartAI just received an 1.2 update, and it's a big one!

    Lot of cool new features in this update that will really help with your productivity and general workflow.
    One of new features I want to talk about here are reflection-based graph elements:
    When developing RVSmartAi rpg pack I realised that writing graph element for every property you want to access and use as scorer or change it, can feel like a bit more work than necessery, especially for prototyping, so idea of reflection-based graph elements naturally came to mind!
    Reflection based graph elements allows you to access any property on your context that have public accessor or setter;
    just add lets say ScoreByNumber scorer, enter name of property you want to use as scorer and voila! That's literally all it takes!

    Same situation with setting properties, just add for example SetInt task under one of yours utilities and enter property you want to set - SetInt also works for enums, so it's great for changing some states in your ai.
    There are also scorers params which work on collection of data and will score based on any property from any object you provide for it.

    This update provides you with all the most useful scorers and tasks like: compare bool, string or number even number remapped by curve.
    For your convenience there is also CallMethod task which can call any public method with no arguments on your context.

    Other production-boosting feature worth noting is common operations on graphs like copy, paste and duplicate graph element from context menu.
    Documentation is also updated accordingly, with better explanation of graph elements.


     
    Catonovato and laurentlavigne like this.
  26. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    1.2 update is live, make sure to read '1.2 update notes ' file located in documentation folder.

    features:
    -graph elements copying, pasting and duplicating, from node's context menu
    -tool for analysis and automatic fixing of AiGraph
    -debugging last score for single scorers in inspector
    -new set of scorers and tasks that are reflection based, see RVModules\RVSmartAI\Content\Code\AI\ReflectionBased\
    allowing to manipulate public properties on context and AiTaskParams parameters via ai graphs
    -scorer types: now you can select math operation for every scorer: add, sub, multiply or divide.
    It operates on result score from all earlier scorers, so if the last scorer is divide, it will divide whole returning score by its own score.

    fixes:
    -graph is destroyed on Ai component OnDestroy
    -script templates using public instead of protected access modifier
    -AiTaskParams - scores below 0 will work properly now
    -AiTaskParams disabling fix
    -general code cleanup
     
    Catonovato and dmenefee like this.
  27. Catonovato

    Catonovato

    Joined:
    Mar 24, 2014
    Posts:
    5
    Just picked this up and I'm really digging it so far. Any idea when we may get an API guide or tutorial? The performance is bloody fantastic(probably the best feature to be honest).

    I hope you can keep up support as Utility extensions seem to be cursed with devs dropping support with little warning :p.

    Really nice use of xNode. Was about to write my own Utility framework with it myself then noticed you had already done the leg work. ::cheers::

    Keep up the good work!
     
    Roni92pl likes this.
  28. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Hey, thanks for kind words, glad you like it!
    With regarding to API guide - there is no docs for api as it's SmartAI is not designed to modify graphs via api, altough there are lot of public methods so it's definitely possible.
    Could you share your use case where using api is needed/necessary?
     
  29. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    Someone’s having something real to show ? Like a real animated enemy shooting, chasing you, taking cover, thing’s like that. I’m glad the performance is on par but would like to see a realistic in game implementation.
     
  30. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Hi, SmartAI is graph-based utility framework, so package itself doesn't contain ready to use behaviours (altough there are ready to use graph elements for creating movement logic without writing any code or you can use ready to use graphs from examples, like follow example) or animations system like you describe, but I understand you want to see it in some more interesting action - im currently working on HonorAi - which is basically addon/package for SmartAi with exactly what you described - animation system, ready to use combat ai that make tactical choices, fights, retreats etc..
    For now I can share this vid i prepared earlier:


    Im actually working on more visually interesting and interactive demo, hopefully will be able to show it next week, cheers.
     
  31. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    Thanks !! Good to know !
     
  32. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Version 1.2.1 is out!
    When working on HonorAI I realised that with growing graph they can get pretty big, and you almost always work on 1-2 nodes, not on all of them at once, so it makes sense to fold rest of nodes so they take a lot less screen space and keep productivity high.

    Unfolded


    Folded


    As you can see it doesn't fold completely, but it just hides tasks under utilities, so you will still have visible connenctions between nodes and all their utilities;
    Hope this feature will make your work with ai graphs easier.
    Press button with arrow in right-top corner of node to use new feature. Cheers :)
     
    twitchfactor likes this.
  33. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    1.3 Update is coming!

    New features:
    -Search bar for adding tasks and scorers:

    Super useful, after it took me more than few seconds to find graph element of my interest it was clear that this small workflow improvement is a must!

    -Secondary graphs:

    Allows you to run multiple graph by one Ai. Of course you can debug all secondary graphs as well.
    Useful for example when you have some tasks that you want to execute every time with no conditions, or just want to have some separate, independent logic in other graph. They don't differ in usage or possibilities from main graph, you can still edit them freely at runtime.

    -Nested graphs!

    Yes, you can finally have reference to other graphs in your graph, and nest them with no depth limitations!
    It is super helpful if your graphs grew big, and it also helps with reusability of graphs, as now you can design graphs more as small, isolated parts of your ai behaviour, like for example have separate melee combat and distance combat graphs.
    To debug nested graph you simply click orange button Enter<graphName> on graph node as seen in image above.
    From there you can also very easily get back to parent graph.


    -AiJobs system:

    Easily create tasks that will take multiple frames to execute, with control when to stop them. Checkout TestAiJob class for example usage.

    -Updated RVLoadBalancer and RVUtilities modules to newest versions


    Cheers
     
    Last edited: Jul 14, 2020
    laurentlavigne likes this.
  34. mike1997

    mike1997

    Joined:
    Jul 1, 2016
    Posts:
    25
    Is this compatiable (modules) with 2d or would i have to do some rewriting?
     
  35. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Hi, the framework is rendering-agnostic, but provided example agent movement script is based on Unity's navmesh agent, and we use Physx queries for scanning environment and spatial awareness.
    If you don't want to use unity's navmesh system that's no problem at all, as all provided graph elements related to movement reference to interface IMovement, not some direct implementation, so you can easily setup your own movement system implementing that interface. Scanners(movement scanner and environment scanner used for spatial queries) are also referenced through interfaces, so it's all flexible.
    Let me know if you need more details.
     
  36. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Another very cool feature coming to 1.3:
    AiTask can now also have scorers, to enable adding scorers for you task you need to inherit from ITaskWithScorers interface, it's empty interface used just to inform system that you want to scorers, so inspector will show them.
    Example usage:

    Code (CSharp):
    1. public class SetCharacterSpeed : CharacterTask, ITaskWithScorers
    2.     {
    3.         [SerializeField]
    4.         [SmartAiExposeField]
    5.         protected float speed;
    6.  
    7.         protected override void Execute(float _deltaTime)
    8.         {
    9.             var speedLocal = speed;
    10.             speedLocal += Score(_deltaTime);
    11.             characterAi.SetSpeed(speedLocal);
    12.         }
    13.     }

    So this allows you to set character speed value based not only to predefined value in graph like earlier, but to get this value from scorers - this allows for example to set character speed based on distance to it's destination remapped with curve, which is exactly what is used for follower behaviour in HonorAi.
    For debugging total score for task with scorers will be displayed next to task name, just like with utilities.
     
  37. mike1997

    mike1997

    Joined:
    Jul 1, 2016
    Posts:
    25
    Very cool, thx for the reply, and for future updates
     
    Roni92pl likes this.
  38. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Hello, just pushed 1.3 update for Asset Store approval. I recommend to create backup and remove all old files(RVModules folder) before updating. This update have some pretty big changes/improvements so as always with such case there is risk of new bugs, so please report any issues/problems, any feedback is also welcome through forum, email or discord.

    Here's changelog for 1.3:
    features:
    -secondary graphs
    -nested graphs system
    -new node type: graph node for referencing other graphs
    -search bar for adding scorers and tasks windows
    -ai jobs system
    -AiTask can now have scorers just like AiUtility

    improvements:
    -automatic and more consistent graph elements' game objects naming
    -lost references to child graph element now automatically fixed
    -automatic null child graph elements removing
    -updated RVLoadBalancer and RVUtilities modules to newest version
    -improvements in movement physx scanner

    fixes:
    -fixed node connection lines not centered in connection ports
    -fixed copying/duplicating nodes in variant graph

    changes:
    -all scorers default score is 1 instead of 0
    -changed max slider value for graph update frequency from 30 to 8
    -removed graphStepsPerUpdate from inspector, by default all graphs will now go through all nodes in one update as there is very little to gain by not going through whole graph in every update and it makes ai behaviour inconsistent
     
  39. mike1997

    mike1997

    Joined:
    Jul 1, 2016
    Posts:
    25
    Already purchased your asset, i like it a lot

    Quick question, is there ecs integration in the future, at least for hybrid apps?

    in 1.3 update
    ai jobs system - made me think of DOTS jobs :)
     
    Roni92pl likes this.
  40. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Hi, Im glad you like it, hopefuly it will be useful!
    Regarding job system - coincidence of naming with DOTS jobs is accidental, I hope it's not misleading.
    SmartAi jobs are more like coroutine(it's not threaded), that you can run from ai graph, but load balanced and with much better performance and api. And for now I don't plan to integrate with DOTS, since it's in way too early stage, and it's also completely different api that is for the most part not compatible with the rest of Unity environment, that would mean probably writing everything from scratch to be DOTS compatible.
    Cheers.
     
  41. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Announcing SmartAi Lite!
    The free, evaluation version of SmartAi will allow you to check out the workflows in practice and learn the concepts of working with graphs and graph elements!
    Lite version is based on 1.0v and won't have all features of full version.
    It should be available on asset store in few days.
    Cheers.
     
    f1chris likes this.
  42. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Hello, SmartAi is getting exciting new feature - data providers.
    Until now all graph elements had tightly coupled data and logic - that is if you have scorer that scores based on distance between your ai and it's destination, it will always compare distance to those two positions.
    If you wanted the same scorer, but just to score to other position you would need create another scorer, with only difference in provided position.That would mean writing (mostly)same code more than once, which is bad practice and should be avoided.

    Data providers for the rescue!
    Data providers are components that will allow way greater flexibility and reusability of graph elements.
    Now instead of providing directly positions to measure distance you can use data providers of Vector3 types.
    That setup will allow you to super easily swap to different data provider of scorer to score to different positions.
    As you can see it creates pattern where you can decouple data from logic - graph elements would be logic, and data providers would well.. provide data :D
    Thanks to such solution instead of writing "proximity to X" scorer, you can write "proximity to position" scorer, and that position can be anything you want based on used data provider.

    Writing data providers is super easy and fast, they are basically one-line of code classes, and they can work on your ai context just like graph elements or you can make them provide values from inspector.

    This is example of how data provider looks like.
    Code (CSharp):
    1. public class MyPositionProvider : PositionProvider
    2.     {
    3.         public override Vector3 GetData() => ContextAs<IMovementProvider>().Movement.Position;
    4.     }
    Code (CSharp):
    1. [Serializable] public abstract class PositionProvider : DataProvider<Vector3>
    2.     {
    3.         public static implicit operator Vector3(PositionProvider _positionProvider) => _positionProvider.GetData();
    4.     }
    This base class PositionProvider is there just so you can treat your position providers as Vector3, so it's very non invasive in graph elements code.

    For gui part you have nice and convenient buttons to assign your data providers, when you press button it will show window with data providers to select from, just like for scorers and tasks.


    Update will of course come with data provider base classes for the most common use cases like floats, animation curves, Vector3 etc.

    Cheers
     
    Last edited: Aug 24, 2020
  43. lolaswift

    lolaswift

    Joined:
    Jan 10, 2019
    Posts:
    151
    2d pathfinding with this asset?
     
  44. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    1.4 progress update

    New feature: graph variables


    Graph variables is (optional) component attached to AiGraph prefab;
    it stores arrays of many of the most commonly used data types in graphs like vector2 and vector3 that are referenced by their name.
    Graph variables are great way to store global variables that makes no sense to be implemented in context(in the meaning that those variables are graph-specific, not relevant for your context class), or just variables that you want to share between graph elements, for example animation curve, so instead of doing prefab from task just to have same animation curve in both tasks you can use graph variables.

    They can also nicely help with limiting the amount of data providers that you need to write, since instead of writing dedicated data provider or even graph element just to access one variable from your context, you may just define that variable in graph variables, which doesn’t require you to write any code.

    Graph variables and data providers complement each other very nicely because you can very easily define some variables and then use them in data providers, since SmartAi comes with many ‘variable providers’ like VariableFloatProvider which is data provider that takes data - in this case float from graph variables.


    Updated data providers gui to be much more compact and convenient;
    Here field 'Position' is of Vector3Provider type.


    Click My Position to select other data provider ->
    Window will show all compatible data providers, in that case of type Vector3.


    At runtime you will also see last value provided by data provider, so you won't be left in darkness.
    It's also handled automatically(no additional code required), and last value will be displayed as long as provided data type is serializable by unity :)



    Stay tuned, that's still not all goodness coming in 1.4 :D
     
    Last edited: Sep 22, 2020
  45. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
  46. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    1.4 progress update
    New feature: Ai references

    Graph variables live on ai graph game object, so they cannot have any direct references to scene or your ai agent objects. To help with that Ai component have ‘references’ field that allow for easy and convenient adding of references from your ai agent or scene to graph variables. Simply add a few in edit time, and they will be added to graph variables at runtime automatically as Unity objects to graph variables.
     
  47. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    1.4 progress update
    New feature: Running tasks
    Running AiTask - this is not actual type, every AiTask can be running task by returning true in overriden IsRunningTask property. Running task differs from basic task in that basic task don't stop execution of graph in any way and is executed immediately, just like normal C# method; while running task allows for writing code that will execute across many frames, and will stop execution of graph until it is finished - this is also important difference between AiJob and running AiTask - AiJob doesn't stop execution of graph. AiTaskParams can also be running task.

    Use cases:
    Running AiTask is very useful is two cases: when you want ai to do something that cannot be interrupted by other ai stuff and you know it takes some time to do, for example playing some animation that shouldn't be interrupted by any other ai action. Second case is load balancing(spreading across multiple frames) heavier AiTasks, like scanning many positions using Physx queries - with 1.4 update Physx movement scanner will get that feature out of box allowing for much more scalable AI with very fine-grained control.

    Btw, because we have already 4 types of aiTask with few possible combinations, I made dedicated doc page(its also linked in updated, online documentation) describing all of them and what they are good for:
    https://github.com/RonisVision/HonorAI/wiki/AiTask,-AiTaskParam,-running-AiTask,-AiJob;--what-are-the-differences,-which-one-to-use-and-when?
     
  48. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Hello, 1.4 update is finally released! As always, backup your projects before updating.

    features:
    -data providers
    -graph variables
    -ai references
    -running ai tasks - every ai task can now 'block' execution of graph until it's finished
    -new tasks and scorers using data providers and load balanced execution
    -load balanced scan method for physx movement scanner (can spread scanning across multiple frames for better performance)
    -default description for AiGraphElement - now you can define graph element's default description in code

    improvements:
    -custom ai load balancer configuration available from inspector and via api
    -improved spatial scanners
    -many new api comments and updated documentation
    -performance improvements in load balancing module

    changes:
    -SmartAiExposeField is made obsolete, no need to use it anymore, from now all serialized fields are exposed just like in any other Monobehaviour
    -some namespaces refactor

    Cheers :)
     
  49. pky

    pky

    Joined:
    Mar 11, 2014
    Posts:
    7
    I got interest about the HonorAI that you show the video in RVSmartAI asset store. Do you plan and when are you release the HonorAI into Unity Asset Store?
     
  50. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Hello, 1.41 update is out and it contains important fixes and improvements, so be sure to update your SmartAi!

    improvements:
    -real time debug info of graph variables in AI inspector for main graph and secondary graphs
    -optimized memory allocations in many places
    -added button in runtime debugging that selects graph owner

    fixes:
    -removed rest of obsolete RVSmartAiExposeField attributes
    -nested graphs will get destroyed when parent graph was destroyed
    -secondary graphs game objects will get destroyed
    -fixed runtime debug node connections highlight for running tasks

    changes:
    -removed 'debug info' showing last evaluated node utility and task from Ai inspector
    -changed GraphVariables class name to Variables
    -AiScanSurrounding task is using FloatProvider instead of normal float for scanRange
    -AiTask StartExecuting now have return value of bool, to decide if running task was actually started or should be ignored
    -MoveToBestPosition divided into two different classes for better control: ScanAndMoveToBestPosition(earlier MoveToBestPosition) and new - MoveToBestPosition
    that works on earlier prepared list of positions; this setup allows to have position scanning and scoring as separate tasks
    (one that scans positions(ScanWalkablePositions) and other that scores them and moves to best one(MoveToBestPosition))