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?
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:
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 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?
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:
1
2
3
4
5
6
7
8
9
10
[EventReceiver("MyEventName")]
publicclassMyTask:ConditionTask{
//Same name as the EventReceiver attribute parameter and of course the event name send.
voidMyEventName(List<GameObject>list){
//stuff...
}
}
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
Author
Posts
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.