Blackboard Variable Types issue

NodeCanvas Forums Support Blackboard Variable Types issue

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #11025
    chocolacode
    Participant

    Hi Gavalakis,

    I hope you are doing well,

    I am trying to test how different variable types can be of benefit for my workflow, so I am testing arrays, Enum and Dictionaries

    these types did not come as default in the node canvas, I have added them from the preferred types panel.

    when I try to use them, I find no way to add values to them.
    If I am inside an action all I see is Abstract(Enum) or Abstract(Dictionary). If I try to add values to them in the variables panel, also not possible

    For your reference I am running version 2.5.6 and attaching a screenshot for your reference

    I am missing a setting?

    Thanks in advance!!

    Attachments:
    You must be logged in to view attached files.
    #11034
    Gavalakis
    Keymaster

    Hey,

    It seems that you have added the abstract System.Enum type. What you need to do instead is add the actual enum you want to use, like for example UnityEngine.WrapMode, not the base type System.Enum.

    Same is the problem for Dictionaries, although Dictionaries are unfortunately not really supported to be used as blackboard variables through the editor at the moment.

    Let me know if adding enums works for you considering the above.
    Thanks.

    Join us on Discord: https://discord.gg/97q2Rjh

    #11037
    chocolacode
    Participant

    Hi,

    it did work as you explained, with any Enum that already has predefined values,

    question.. is there an option where I can create my own Enum and I define my own values? how can I do that?

    thanks in advance!

    one more question. Is the Dictionaries functionality planned in the short or long term?

    #11041
    Gavalakis
    Keymaster

    Hey,

    Enums are simply types which can be created in code likeso:

    Dictionaries is something I’d like to support for variables added through the editor in the future, but I can’t really promise as of when this will be possible 🙂

    Join us on Discord: https://discord.gg/97q2Rjh

    #11045
    chocolacode
    Participant

    Hi there,

    that Enum code worked! thanks for that,

    hopefully you find some time in the future to implement the dictionaries through the editor. So at this point how can use them now in nodecanvas outside the variables editor?

    I am working in a fsm and want to manage a list with enemies with name and power and want to be able to locate them by name. So I want to interact the ism and perhaps some bit of coding, but can you provide me a short example with screenshots or gifs? is it possible?

    thanks in advance!

    #11046
    Gavalakis
    Keymaster

    Hey,

    You are welcome. 🙂

    You can use the Blackboard API to add any type of variable outside the variables editor and through coding. That includes adding Dictionary types.
    For example, if you add this script on the gameobject that the blackboard is, you will be able to add a dictionary type through the script’s context menu, which you can do in the editor as well.

    Even doing so, there are no existing actions for dictionaries though, so creating custom ones to do what you want will be required. I can help you with that of course.

    Regarding your 2nd question, can you please provide a bit more info on what you will require to do with this list of enemies variable? Is “Enemy” some custom MonoBehaviour script you have created?

    Let me know.
    Thanks.

    Join us on Discord: https://discord.gg/97q2Rjh

    #11047
    chocolacode
    Participant

    Hi there,

    thanks very much for your answer, that gave me a good start. 🙂
    regarding my 2nd question. I actually I am looking into a solution to add enemies names(string) and power(int) into a dictionary. Then I want to locate from a game object manager by name and update the corresponding power.

    May I ask you a favor? can you help me to create a couple of custom actions… 1 for adding entry to the dictionaries variable and 1 for getting the value for a specified key. If then I will check how you did them and I will try to do the rest I am planning(count property, delete an entry, clear dictionary, iterate, etc.)

    please let me know if that is possible,

    thanks in advance!

    #11057
    Gavalakis
    Keymaster

    Hey,

    Sure 🙂
    Bellow are the 2 Dictionary related actions you requested. Notice that both of these actions are able to work with any type of value, but only string for key. Since only one generic argument is supported in NodeCanvas at the moment, I chosen it to be string, since it is the most commonly used one of course 🙂

    Both can be found under category “Blackboard/Dictionaries”. Like the rest of the generic tasks, you simply have to choose integer for your case like for example “Blackboard/Dictionaries/AddElementToDictionary (T)/AddElementToDictionary(Integer)”.
    Let me know if these work for you.

    AddElementToDictionary.cs

    GetDictionaryElement.cs

    DictionaryTasks

    Join us on Discord: https://discord.gg/97q2Rjh

    Attachments:
    You must be logged in to view attached files.
    #11081
    chocolacode
    Participant

    AWESOME!!

    thanks Gavalakis! this will help me a lot!!

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.