Creating custom FSM connections with predefined conditions

NodeCanvas Forums General Discussion Creating custom FSM connections with predefined conditions

This topic contains 4 replies, has 2 voices, and was last updated by  olaf 7 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #12145

    olaf
    Participant

    Hello everyone,

    I bought this fantastic plugin to use it in an unusual scenario with my custom nodes. I need to manually setup a network of tenths of nodes in FSM which will have the exact same transition condition which responds to an event:

    if an event string argument == node.name, then perform the transition

    So I started to setup those connections manually but it’s super time consuming when you have so many nodes. What I’d like to do is to write a custom connection which would already contain this condition (preferably hardcoded). I imagine that I would hold a modifier key and then drag the connection – in which case my custom connection would be made in GUI graph editor. Could someone assist me how to start and what classes should I dig to make this kind of modification?

    Any help would be appreciated 🙂

    Thanks!
    Olaf

    #12154

    Gavalakis
    Keymaster

    Hello Olaf,

    Thanks a lot for your positive feedback!
    Are you referring to altering the source code for the Editor GUI, or referring to creating some custom condition which you want to be assigned on the transitions?

    If you want to alter the code so that all transitions/connections already come with a condition assigned, then probably the best way to do this, would be to open up the FSMConnection.cs and add these lines of code in the class, replacing the condition type with the type you want:

    
    		public override void OnValidate(int sourceIndex, int targetIndex){
    			if (_condition == null){
    				_condition = Task.Create<Tasks.Conditions.CheckBoolean>(graph);
    			}
    		}
    

    This is of course not really recommended since you will be altering the source code.
    Can you please clarify if this is indeed what you are after?

    Thanks!

    #12172

    olaf
    Participant

    Hi Gavalakis,

    Yes, that’s exactly what I needed 🙂 I wanted to alter the editor GUI. Thanks for the hint, but in the meantime I realised it’s quite easy to copy-paste connection tasks as well so I made a custom condition task instead. It still needs some clicking but not that much.

    What would really make my graph setting up much easier – would be the ability to duplicate the node (as in ctrl+d) but with maintained all the connections same as in the original node. Wow, that would be something 🙂 Could you guide me on where to start to make it happen?

    Thanks!

    PS. sorry for my delayed response, apparently I missed an email notification

    EDIT: I tried the snippet you provided – it works great! Many thanks! Although the mentioned above copy-pasting with maintained connections feature would be super helpful as well 🙂

    #12176

    Gavalakis
    Keymaster

    Hey,

    You are very welcome 🙂
    I am glad to know that you’ve found the copy/paste between connections to be usefull!
    I will take a look at your suggested feature here and see what is possible with it as well.

    Thanks!

    #12177

    olaf
    Participant

    I’ll be looking forward to it! 🙂

    Thank you!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.