playMaker

Author Topic: UI event affect prefab broadcast target?[SOLVED]  (Read 1063 times)

andrewgideon

  • Playmaker Newbie
  • *
  • Posts: 6
UI event affect prefab broadcast target?[SOLVED]
« on: February 17, 2020, 06:09:16 AM »
When a PrefabA is generated, PrefabA will broadcast immediately, and ObjectB on the scene will receive this event
so, ObjectB use <Get Event Send by>, you can get the object = prefabA => OK

If you use action (ex. <UI button on click Event>) before generating PrefabA,
     Then ObjectB uses <Get Event Send by> to get the object => button obj? Why?
Not expected~~
This action (ex. <UI button on click Event>) is only executed on the scene and has nothing to do with Prefab, but it will affect Prefab's event trigger .....

Please tell me why?
« Last Edit: February 19, 2020, 07:05:39 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: UI event affect prefab broadcast target?
« Reply #1 on: February 17, 2020, 07:38:27 AM »
Hi,

 Was the prefabA instance generated because it received that button click event?

you are likely within a typical race condition with the event data and the events themselves.

 event data is a public static variable, which means it's the same for everyone regardless of what even has been fired, so in your case, you are likely in the case where playmaker has updated the event data because it received the click event, but your fsm are still proceeeding other event thinking they are still in that "context".

to solve this, wait the next frame for your prefabA instance to fire that event, it tempers this kind of race condition.

try to also fill the event data GameObject variable with the owner of who is sending this event, this could work in your case, instead of relying on the event data sender variable.


Bye,

 Jean

andrewgideon

  • Playmaker Newbie
  • *
  • Posts: 6
Re: UI event affect prefab broadcast target?
« Reply #2 on: February 17, 2020, 08:31:28 AM »
Thanks for your comments~

without button click to spwan prefab~
try..

I create emptyGameObject , and set FSM   <start state>  wait 10s and then
<create  Prefab> to try this case.
and
Prefab obj <start> wait 3s  and broadcast  event.
I have enough time to observe and test whether the <UI action change event> affects

the same problem occur~!
Can you give me a more detailed solution?


andrewgideon

  • Playmaker Newbie
  • *
  • Posts: 6
Re: UI event affect prefab broadcast target?
« Reply #3 on: February 17, 2020, 09:29:16 AM »
Finally, thank you for your last suggestion

try ..
I set Action: <Set event data> in <Prefab>
<Gameobject Data>: get owner
and then action: <send event>
In the receive event:
<Get Event info>: get gameobject data
ok ~~~ I can get the Prefab object ~~~