playMaker

Author Topic: Send Event - Send to Children problem[SOLVED]  (Read 1887 times)

szomaza

  • Sr. Member
  • ****
  • Posts: 253
Send Event - Send to Children problem[SOLVED]
« on: June 18, 2019, 11:15:09 AM »
I have been trying to figure this out for a day where the problem is but unfortunately I can't reproduce it in a test scene.

I use send events a lot.

In this case there is a hierarchy, into which I parent an object and later another one next to it under the same parent object so it becomes the 2nd sibling there.
Later I use the Send Event action and send an event to one of their parent higher up in the hierarchy.

Event target is Game Object and I have "Send to Children" ticked TRUE.
This should send the same event to all child objects, but here is what I experience:
1. Only the 1st sibling receives the event, the FSM with the same event in the 2nd sibling remains in Start state. (does not receive the event)
2. In case I set the 2nd object parented there to be the 1st sibling, that is the one which will receive the event and the other one does not.
3. In case I do the Send Event 2 times, right after each other then both of the objects receive it.

Unfortunately I am unable to figure out what I am doing wrong or where is the problem:
I have set this same thing up in a test scene with more objects (empty objects with just test FSMs), even doing some parenting, but when I send the event to the parent of the hierarchy, all objects receive it.

Does anything come to mind I should try?
Please share any idea.

Br,
szomaza
« Last Edit: July 04, 2019, 04:41:25 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Send Event - Send to Children problem
« Reply #1 on: June 19, 2019, 03:41:06 AM »
Hi,

 could it be a race condition that within the sequence of PLayMaker sending this event to the list of FSM listening to that event, one of the state fires another event that make a given fsm jump to another state and miss the original event you sent?

 It happens to me quite often, basically, a cascade of chain events affecting the same fsms can create this kind of trouble.

you need to cut down features, for example, all fsm listening to that event, should not do anything, disable all actions and let fsm stay on the receiving state, fire the event and check that all is sound, then add features back one by one.

 Or do the opposite, take one feature out and test until you can't repro, then you narrow down the area giving trouble.

 Bye,

 Jean

szomaza

  • Sr. Member
  • ****
  • Posts: 253
Re: Send Event - Send to Children problem
« Reply #2 on: June 21, 2019, 05:45:05 AM »
Hi Jean,

Thank you, that is a good suggestion to check, as I have made that error before: sending an event to an FSM while it was still working on something else.

In this case the FSM waiting to receive the event is just in the empty Start state, not doing anything. ... and stays there even a second after the other sibling's FSM has already received the same event.

What about this fact, does it ring any bell?
- The FSM in the 1st sibling (in the hierarchy I am sending the event to with "Send to Children" ticked TRUE) always receives the event and the FSM in the 2nd sibling never does.
- If I change their sibling order before sending. then it is again ONLY the 1st one which receives it.

This works like this (or does not work in this case :-) ) every time.

This is also peculiar:
- In case I do the Send Event 2 times, right after each other then both of the objects receive it.

I'll keep trying to figure it out, instead of just using this or other workaround , as such things worry me for reasons.

szomaza

  • Sr. Member
  • ****
  • Posts: 253
Re: Send Event - Send to Children problem
« Reply #3 on: June 21, 2019, 06:17:15 AM »
YAY! I figured something out.

Instead of removing features as you suggested  :) I added more: instead of just having 2 siblings there I spawned 3 more thing there so there are 5 siblings now which should receive the same event.
Here is what I am noticing:
- 3 out of the 5 always receive the event and 2 never receive it.
- AND the 2 not receiving the event are always the 2nd and the 4th sibling.

So 1st, 3rd and 5th always receive the event (which should be sent to all children) but the 2nd and 4th never do.

edit:
Note: the siblings getting the event parent themselves away from the hierarchy, so 1st there are 2 of the 5 remaining there, then if I send the event again after a short wait there remains always 1 of the 2 which does not receive the event.

And now I am like: "Hmmm is there an error in the code that deals with sending the event to all children"
But on the other hand I tried to reproduce this in a test scene and there all the test objects received the event properly.
« Last Edit: June 21, 2019, 07:08:25 AM by szomaza »