Alternator Decorator?

Forums 💬 NodeCanvas 🗨️ General Discussion Alternator Decorator?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #14990
    grofit
    Participant

      I am not sure if this functionality can be achieved already, it sounds similar to the Toggle but I didn’t really get how that one should be used.

      So you have 1-N varying actions and every time the decorator is hit, it will get the first of its actions and yield back up to its parent object, like a sequencer but stateful.

      So here is an example scenario, you have a start point and an end point, you want to go from start to end, then from end back to start. So the logic would be something like:

      – Get Start Position
      – Get End Position
      – Make Start Active Waypoint
      – Move To Waypoint
      – Make End Active Waypoint
      – Move To Waypoint

      However if there was some form of alternating decorator you could do

      – Get Start Position
      – Get End Position
      – Make {alternate start, end} Active Waypoint
      – Move To Waypoint

      As the 2nd time around it would alternate to the other destination.

      Hopefully you can see the sort of use case where it could be useful (Although I am not sure how useful it would be in the wider scheme of things). I guess if it is already possible how would you do it, and if not would you deem the above possible and useful?

      #14993
      Gavalakis
      Keymaster

        Hey,

        Toggle is a meta-operation which modifies the behaviour tree’s root/start node, so I think that it’s not really what you are after 🙂

        Even though your desired behaviour can be achieved with some ways, I really like your suggested node to make it easier, kind of a Selector that will alter the order of it’s child nodes in some way.
        What came to my mind is a Composite that uses it’s child nodes kind like a ‘Stack’, pushing and looping the indexes forward (or backward) after each execution, something like this (4 child nodes):
        0,1,2,3
        3,0,1,2
        2,3,0,1
        etc…

        I am not sure if thats clear 🙂

        So in effect if you have just 2 childs, it will alter between those 2 after each complete execution of the node.
        I will give some more thought on that of course, but yes, nice idea 🙂

        Thanks

        #14992
        dsedov
        Participant

          Here is something similar (character goes between waypoints and starts over when he reaches last waypoint) Waypoints are stored as a list.

          #14991
          grofit
          Participant

            Your implementation seems to do what I need so would be happy with that.

            Thanks for the example script, I already have stuff following waypoints and starting over, I could just think of a better way to do it if you could alternate a variable.

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