playMaker

Author Topic: sync data from two objects  (Read 4228 times)

mekoid

  • Playmaker Newbie
  • *
  • Posts: 36
sync data from two objects
« on: April 12, 2015, 12:08:13 PM »
Hi
This started to give me a headache. guess this might be a newbie question.

I need to get data from 2 objects ( I send 2 events to them and from each of them---> triggering event(get the connecting object)---> get fsm variables from the connecting objects ---> set fsm variables back ---> send events back to the controlling object ) almost at the same time, and wait for both of them to return values and then make comparisons.
How can I make sure both of them return before I can do the next?!?!
So far I only set return event from one of them, and that gives me uncertain results.

Any good suggestions please? Thanks very much in advance!
« Last Edit: April 12, 2015, 12:19:44 PM by mekoid »

mekoid

  • Playmaker Newbie
  • *
  • Posts: 36
Re: sync data from two objects
« Reply #1 on: April 12, 2015, 12:29:55 PM »
if I send event back to the same global event from both of them, it seems ok.
But I feel it's not a very smart way to do this, I guess? cuz one event might be later than the other and during the time difference, it might have executed some unwanted result before the later event gets sent back...

As you can see, I am no programmer. Just wondering what's the proper way to do under this circumstance...
Thanks

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: sync data from two objects
« Reply #2 on: April 12, 2015, 05:46:29 PM »
Do you have it set so multiple FSMs run at the same time?  So once the FSMs have finished, and the variables have returned,  you can do the comparing.

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: sync data from two objects
« Reply #3 on: April 12, 2015, 08:47:14 PM »
For something like this I would probably use Behavior Tree's w/FSM's-

I'm not a coder either- but when doing AI stuff in Playmaker and having to run multiple FSM's in parallel that talk to each other I found it could get messy and confusing-

Behavior tree's are much better at doing these sort of things as they can run actions/tasks in parallel-

So when I have problems like this I use Behavior Designer https://www.assetstore.unity3d.com/en/#!/content/15277

It's another asset but its REALLY USEFUL and its as easy as Playmaker and you can use it to send data back and forth to/from Playmaker with SendEvents as it comes with Playmaker actions and has its own built in Event system that is just like Playmakers-

So you might want to check it and behavior trees out- here's a good article on them http://www.gamasutra.com/blogs/ChrisSimpson/20140717/221339/Behavior_trees_for_AI_How_they_work.php

They are not just for ai and something that would be really difficult to create with FSM's is simple and easy with behavior trees

Using both FSM's and behavior tree's together gives you a lot of options and could probably simplify your current task-
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

mekoid

  • Playmaker Newbie
  • *
  • Posts: 36
Re: sync data from two objects
« Reply #4 on: April 13, 2015, 11:56:15 AM »
oh wow, mdotstrange, thanks very much for sharing your experience. It opens up a whole new tool for doing my stuffs. I knew about Behavior Designer, but I didnt know it can work with PM. Hope it's as simple as PM. I am gonna spend some time studying it first. Again, thanks so much for sharing!

Splankton:
yes, I did. I even set up an extra FSM to fetch the data. I was just wondering how a programmer would do under this circumstance. Even PM is so much simplified from coding, the FSMs still flow the same way as the coding. That's why I was wondering so.

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: sync data from two objects
« Reply #5 on: April 13, 2015, 08:48:46 PM »
Yeh Behavior Designer is really Playmaker friendly- the developer is awesome too he's added a ton of stuff I've requested to make it player better with Playmaker on his forums-

Its a lot like Playmaker- just have to wrap your head around the order of operations and the node types- that article really helps with that- once you understand it gives you a ton of possibilities-

Also if you are going to do any AI with it- grab the "movement pack" as well
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!