Moving child nodes of priority selector should keep priorities intact

NodeCanvas Forums Support Moving child nodes of priority selector should keep priorities intact

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #14544
    derkork
    Participant

    I’m currently prototyping a utility AI and use the priority selector to select certain actions. The weights of the priority selector are represented by blackboard variables which are dynamically calculated, so priorities can change depending on what state the agent currently is in.  Now I noticed that when moving nodes around on the board that the priority assignments shift. E.g. see the image below, when I move the “Idle” node which has assigned the “$idlePriority” to it between the “Harvest” and “Go Home” nodes, it suddenly gets the “$harvestPriority” assigned while now the “Go Home” node has the “$idlePriority”. Since I move nodes around all the time this is very annoying and can easily introduce bugs.

     

    #14551
    Gavalakis
    Keymaster

    Hello there,

    While this is not a bug but rather designed to work this way, I do understand that it also isn’t the most convenient thing to happen especially in this case of the Priority Selector. I will have to think of a way around this. Would being possible to re-order the Priorities list in the inspector be adequate as aquick solution, if “sticking” them is not. To make them stick, I will probably need to change the Priority Selector serialization (thus break backwards compatibility) or make a new Priorty Selector to avoid this from happening. I will look into this though.

    Let me know what you think about the quick solution of re-ordering.
    Thank you!

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

    #14552
    derkork
    Participant

    So I figure you re-order the connections so the graph doesn’t look ugly with all the crossed connections and I totally see why this is desirable behaviour. However if the connections have meta-information attached to them (like weights or priorities) these really should move with the connection otherwise this becomes quite confusing and sometimes you may not even notice it until you see strange behaviour in the game. I dug a bit into the code and I think I found a way to fix this without breaking the serialization.

    In Editor.Nodes.cs in the TrySortConnectionsByPositionX function I remember the old sorting of the list:

    It basically just sorts the connection metadata such that the order is consistent with the newly sorted connections. And I believe this should not have any effect on serialization as I don’t introduce any new fields. It is basically your suggestion with the inspector, just automated. Now the same thing could be implemented for every node type that tracks connection metadata (e.g. most of the selector nodes). And if you really want to keep the connection metadata and just want to move the node (as it is now) you could press e.g. the CTRL key and this would then just not call OnChildrenReordered.

    #14553
    derkork
    Participant

    On a related note, this forum really needs a code block 🙂

    #14561
    Gavalakis
    Keymaster

    Hey!
    Yep, I think that adding such a callback in the TrySortConnectionsByPositionX() method and handling this per-case (meaning per-node) is probably the best solution. I can’t see any problems with your code at all. I will probably do this or something very similar for the next version (after the one I’ve submited yesterday by the way 🙂 )

    Thanks!

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

    #14562
    Gavalakis
    Keymaster

    Oh. You can add code blocks with tilda at the start and at the end by the way. Exactly like you did to TrySortConnectionsByPositionX 🙂

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

    #14566
    derkork
    Participant

    Ah backticks it is. It still seems to butcher [ i ] because it probably is a tag for italic text, but good to now 🙂 Thank you very much!

    #14570
    Gavalakis
    Keymaster

    Hey. You are very welcome! 🙂
    Yeah, I still can’t figure out exactly how to work around this [ i ] butchering issue. I will take another look at this since it is very anoying indeed 🙂

    Thanks!

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

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