FSM Send Event with Multiple parameters

NodeCanvas Forums General Discussion FSM Send Event with Multiple parameters

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #10961
    chocolacode
    Participant

    Hi Gavalakis,

    I need to send an event from one FSM to another FSM, at the same time sending various parameters, Floats, ints and booleans.

    but basically the question is if I can send an event with one or several variables and then also I want to perform some operations on the receiving FSM and send back some resulting parameters.

    Is this possible? if so, can you please send me in the right direction?

    thanks in advance!

    #10964
    Gavalakis
    Keymaster

    Hey,

    You can do something like this using the generic versions of SendEvent and CheckEvent tasks. The generic (T) versions of all tasks are able to work with any type of parameter, but right now only one parameter is possible. For example:

    In FSM A, use the SendEvent(T) and override the Self parameter to reference the target FSM B.
    In FSM B you can use the CheckEvent(T) of the same type, to catch the event and store the T data send to a blackboard variable.
    You can then repeat the process from FSM B to FSM A if you want.

    For your convenince, here is what I mean by overriding the Self parameter:
    Override Self Parameter

    Please let me know if you need any clarification on the above and of course if this works for you, or you have any alternative workflow to suggest? 🙂

    Thanks!

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

    #10970
    chocolacode
    Participant

    Hi There,

    Thanks for your answer, I need
    To test what you propose but I think it will work partially.
    I have a case where I need to send
    4 game objects and a Boolean
    from manager A, fsm A to a
    manager B (fsm B)
    which then process
    the information and send back
    a Boolean to the original fsm A.
    Fsm A now will send 1 float and 1
    Boolean to a score manager(fsm C).

    I have a question. You say that
    at this time there is only one
    parameter can be send. are you
    planning on enabling more than
    one parameters of each type at
    the same time?

    Thanks in advance !!

    #10977
    Gavalakis
    Keymaster

    Hello,

    There is indeed a plan to allow more parameters in events yes, but can’t promise as of when this will be ready.
    If you want to pass 4 gameobjects, then probably the best way to do it, would be to use a List<GameObject> using SendEvent<List<GameObject>> as a parameter and then use a CheckEvent<List<GameObject>> and finally save the list to the blackboard.

    If you want to handle the event manually (which seems better in your case), you can create a custom task and use the [EventReceiver] attribute. Here is an example:

    Let me know if that helps, or if you have any ideas to suggest of course.
    Thanks.

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

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