Playmaker Forum

Playmaker News => General Discussion => Topic started by: seldomU on April 12, 2016, 06:43:10 AM

Title: A graph of inter-FSM events
Post by: seldomU on April 12, 2016, 06:43:10 AM
Update:
The PlayMaker communication graph is now shipped as part of RelationsInspector. As part of the launch, the full version is 50% off for a short time. Get it here:
Documentation (https://seldomu.github.io/riBackends/PlayMakerFsmCommunicationBackend/)

Original post:
Hello,

I'm developing a graph visulazing tool for Unity and would like to add PlayMaker support to it. In particular, I want it to show how FSMs are connected through events. Currently it looks like this:

(https://raw.githubusercontent.com/seldomU/seldomu.github.io/master/assets/PlayMakerFsmLinks.gif)

The gif shows the PlayMaker window next to the graph window. All scene FSMs are shown as nodes, the events sent between them are shown as edges. When a node is selected, PlayMaker will select that FSM. Edge markers show their event name as tool tip and allow you to open the state that sends the event as well as the transition that receives the event via context menu.

As a PlayMaker novice, I'd be happy about any feedback and critique. I've tested only with the sample scenes and would like to see what the graph of a real project looks like.

If you want to install it, these are the steps:
Title: Re: A graph of inter-FSM events
Post by: Alex Chouls on April 12, 2016, 09:37:15 AM
Looks very cool! I'm going to try it out...
Title: Re: A graph of inter-FSM events
Post by: MS80 on April 12, 2016, 01:39:44 PM
 :o That looks damn cool and handy!
Something I was missing, a simple way to see how all the FSMs work together!

EDIT: checked it out, really nice start, here is some feedback / questions:
- only "public" events will show up in RI
- does not show events send to "FSM component"
- does not show events send by "send event by name"
- some bugs (f.e. playmakerbackend disappear after switching backends)
- a auto update function would be nice (f.e. update RI every XX frames)
- do you think it would be possible to illustrate shared variables, too (f.e get fsm float, set fsm float)?
- do you plan to sale a RI playmaker version or is RI Pro the only option?
- what about "call method" and "send message"? is it possible to mix backends, it would be handy to see the fsm events and the messages to or from other scripts as well?

btw: RI is great, had a look at the other backends  ;)
Title: Re: A graph of inter-FSM events
Post by: seldomU on April 13, 2016, 02:51:10 PM
Thank you for the kind words :)
Title: Re: A graph of inter-FSM events
Post by: Alex Chouls on April 13, 2016, 04:06:33 PM
Quote
Auto-refreshing the graph every x frames seems like overkill. The Rebuild button let's you do it manually. Maybe I'll make it a toolbar option.

You could used the EditorWindow OnHierarchyChange event to rebuild the graph... or make that an option. Maybe in EditorWindow OnFocus as well.

I could also expose a delegate in the Playmaker editor when the FSM has been edited, so you could hook into that.
Title: Re: A graph of inter-FSM events
Post by: seldomU on April 14, 2016, 11:34:15 AM
I could also expose a delegate in the Playmaker editor when the FSM has been edited, so you could hook into that.

That would be great. In the meantime, I'll make it optionally rebuild on scene changes.

I have a problem with SendEventByName: its event name field dropdown contains variables instead of events. Am I doing something wrong? SendEvent actions work fine.
Title: Re: A graph of inter-FSM events
Post by: Alex Chouls on April 14, 2016, 12:12:27 PM
Send Event By Name is designed to work with strings. So the dropdown shows string variables. It gives you a little extra flexibility to change the event sent at runtime. It could use a little browse button to set the string value to valid event names, like we do with animation names., but never got round to it. Most of the time you should be using Send Event, so it never became high priority...

Does that make sense?
Title: Re: A graph of inter-FSM events
Post by: jeanfabre on April 14, 2016, 10:57:32 PM
Hi,

 Also, one useful feature would be study and represent where events are fire using the api. I am doing a lot of monobehaviours acting as proxies for firing "system" events. Like for the new UI system. In Many projects, this is playing a important role in the logic flow.

I don't have a solution unfortunatly, other than declaring an attribute to use ( Like I do in PlayMaker Utils), but that means compatibility issues if that attribute is not declared within PlayMaker.


Bye,

 Jean

Title: Re: A graph of inter-FSM events
Post by: seldomU on April 15, 2016, 02:52:25 AM
Attached is the new version that adds support for SendEventByName actions and FSM Component targets.

@Alex: yes that makes sense. Btw, I can't use the hierarchy-change event for rebuilding the graph. It doesn't fire when FSM actions are modified.

@jeanfabre: I don't understand. Are we talking PlayMaker events or Unity events? There already is an add-on for Unity UI events (http://forum.unity3d.com/threads/ui-event-inspector.387532/).
Title: Re: A graph of inter-FSM events
Post by: MS80 on April 16, 2016, 03:36:31 AM
Thanks, "send event by name" (also non global ones) and "FSM component" work just fine now!  :)

  • A shared variable graph is possible. Would you want it merged into the event graph or separate?
  • Graphs for called methods and sent messages are possible too. Mixing them is a bit tricky, but I can see how that would be useful.
Great! Visible fsm events, fsm variables and communication to or from scripts would give one a good and quick project overview! I think it would be handy to have those in one backend view, maybe different icons / colors for events, variables and messages (methods)?!

Is visual debugging (like in playmaker FSMs) planned for RI? To see what's going on in runtime would be very helpful!
Title: Re: A graph of inter-FSM events
Post by: jeanfabre on April 17, 2016, 10:52:50 PM
Hi,

 I am talking about PlayMaker events yes. I have created multiple systems that allow developers to catch Unity events and forward them as PlayMaker events, and that happens within regular Monobehaviours.

There's a video explaning the basics:



Again, I am not sure it's practical for you to start looking outside PlayMaker, but in this case  (as for all the proxies for PlayMaker you find on the Ecosystem), I created a standardized way of declaring these. It's not 'official' however.


 Bye,

 Jean
Title: Re: A graph of inter-FSM events
Post by: seldomU on April 23, 2016, 08:08:54 AM
Thanks, "send event by name" (also non global ones) and "FSM component" work just fine now!  :)

Nice! :)

I added relations for variable access between FSMs to the event backend, as you suggested. The new version is attached. Here (https://seldomu.github.io/riBackends/PlayMakerFsmCommunicationBackend/) I wrote basic documentation.

(https://raw.githubusercontent.com/seldomU/seldomu.github.io/master/assets/BackendPages/PlayMakerCommunicationBackendExample.png)

Is visual debugging (like in playmaker FSMs) planned for RI? To see what's going on in runtime would be very helpful!

That's beyond the scope right now, but could be added in a future version, provided that PlayMaker's public API allows it.

@jeanfabre: That seems really useful. Right now I only want to cover PlayMaker's own features though.
Title: Re: A graph of inter-FSM events
Post by: mdotstrange on April 23, 2016, 09:06:38 AM
Wow- the ability to see Playmaker events in the graph like that is really useful- I will be buying your asset-

I'm able to see the variables set if I use "Set Fsm Variable"- they don't show up if I use "Set Fsm Float" o"Set Fsm Game Object"- it would be awesome if variables using those set/get actions showed up as well- unless they already do and there's a trick to it?

Awesome asset anyway  :)
Title: Re: A graph of inter-FSM events
Post by: seldomU on April 23, 2016, 10:08:12 AM
Thank you for the purchase!

I had only considered the Get/Set Fsm Variable actions, I didn't know about the others. I'll add all the Get/Set Fsm ... actions shortly. Are there any others I should include?
Title: Re: A graph of inter-FSM events
Post by: rik on April 23, 2016, 10:29:06 AM
HI
i have just imported the demo version and also the unity package posted here and now i am trying to see playmaker graph but i dont see any option to do that
Title: Re: A graph of inter-FSM events
Post by: seldomU on April 23, 2016, 10:47:32 AM
HI
i have just imported the demo version and also the unity package posted here and now i am trying to see playmaker graph but i dont see any option to do that

Hi,
these steps should get you a graph for your active scene:
Title: Re: A graph of inter-FSM events
Post by: mdotstrange on April 23, 2016, 10:49:28 AM
Thank you for the purchase!

I had only considered the Get/Set Fsm Variable actions, I didn't know about the others. I'll add all the Get/Set Fsm ... actions shortly. Are there any others I should include?

With event's and the get/set fsm actions covered- I can't think of any other Playmaker stuff that is otherwise difficult to debug- it would be a huge help with just those  :)
Title: Re: A graph of inter-FSM events
Post by: rik on April 23, 2016, 11:07:26 AM
unfortunately in the drop down i dont see playmaker
Title: Re: A graph of inter-FSM events
Post by: rik on April 23, 2016, 11:12:00 AM
i have reimported the script now i get error
NullReferenceException: Object reference not set to an instance of an object
RelationsInspector.Backend.PlayMaker.PlayMakerInterFSMCommunicationBackend.<GetSceneTargets>m__30 (.PlayMakerFSM pmFSM) (at Assets/Editor/GraphBackends/PlayMaker/PlayMakerInterFSMCommunicationBackend.cs:191)
System.Linq.Enumerable+<CreateWhereIterator>c__Iterator1D`1[PlayMakerFSM].MoveNext ()
System.Collections.Generic.List`1[PlayMakerFSM].AddEnumerable (IEnumerable`1 enumerable) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:128)
System.Collections.Generic.List`1[PlayMakerFSM]..ctor (IEnumerable`1 collection) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:65)
System.Linq.Enumerable.ToArray[
Title: Re: A graph of inter-FSM events
Post by: rik on April 23, 2016, 11:15:17 AM
i am getting error when i set the type to playmaker fsm and select active scene i get the following error.
i am using 5.3

NullReferenceException: Object reference not set to an instance of an object
RelationsInspector.Backend.PlayMaker.PlayMakerInterFSMCommunicationBackend.<GetSceneTargets>m__30 (.PlayMakerFSM pmFSM) (at Assets/Editor/GraphBackends/PlayMaker/PlayMakerInterFSMCommunicationBackend.cs:191)
System.Linq.Enumerable+<CreateWhereIterator>c__Iterator1D`1[PlayMakerFSM].MoveNext ()
System.Collections.Generic.List`1[PlayMakerFSM].AddEnumerable (IEnumerable`1 enumerable) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:128)
System.Collections.Generic.List`1[PlayMakerFSM]..ctor (IEnumerable`1 collection) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:65)
System.Linq.Enumerable.ToArray[
Title: Re: A graph of inter-FSM events
Post by: seldomU on April 23, 2016, 11:26:25 AM
I'm using 5.3 as well. Attached is an update that fixes the NullReference exception, but I suspect that's only a symptom, not the actual error.
Title: Re: A graph of inter-FSM events
Post by: rik on April 23, 2016, 11:46:26 AM
i have got new error when i open a huge scene with many fsms

NullReferenceException: Object reference not set to an instance of an object
RelationsInspector.Backend.PlayMaker.PlayMakerInterFSMCommunicationBackend+<GetEventReceivers>c__AnonStorey15.<>m__34 (.PlayMakerFSM pmFSM) (at Assets/Editor/GraphBackends/PlayMaker/PlayMakerInterFSMCommunicationBackend.cs:251)
System.Linq.Enumerable+<CreateSelectManyIterator>c__Iterator12`2[PlayMakerFSM,HutongGames.PlayMakerEditor.FsmInfo].MoveNext ()
RelationsInspector.Backend.PlayMaker.PlayMakerInterFSMCommunicationBackend+<GetRelations>c__Iterator3.MoveNext () (at Assets/Editor/GraphBackends/PlayMaker/PlayMakerInterFSMCommunicationBackend.cs:92)
System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10`2[RelationsInspector.Relation`2[PlayMakerFSM,RelationsInspector.Backend.PlayMaker.FsmLink],RelationsInspector.Relation`2[PlayMakerFSM,RelationsInspector.Backend.PlayMaker.FsmLink]].MoveNext ()
RelationsInspector.GraphBuilder`2[PlayMakerFSM,RelationsInspector.Backend.PlayMaker.FsmLink].AddRelations (RelationsInspector.Graph`2 graph, IEnumerable`1 entities, RelationsInspector.GetRelations getRelations, RelationsInspector.RNG rng, Int32 maxNodeCount)
RelationsInspector.GraphBuilder`2[PlayMakerFSM,RelationsInspector.Backend.PlayMaker.FsmLink].Build (IEnumerable`1 seeds, RelationsInspector.GetRelations getRelations, RelationsInspector.RNG rng, Int32 maxNodeCount)
RelationsInspector.Workspace`2[PlayMakerFSM,RelationsInspector.Backend.PlayMaker.FsmLink].InitGraph ()
RelationsInspector.Workspace`2[PlayMakerFSM,RelationsInspector.Backend.PlayMaker.FsmLink]..ctor (System.Type backendType, System.Object[] targets, RelationsInspector.GetAPI getAPI, System.Action Repaint, System.Action`1 Exec)
System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:513)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:519)
System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:528)
System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Activator.cs:338)
System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Activator.cs:274)
RelationsInspector.RIInternal.CreateWorkspace ()
RelationsInspector.RIInternal.InitWorkspace ()
RelationsInspector.RIInternal.OnSelectBackend (System.Type backendType)
RelationsInspector.RIInternal+<>c__DisplayClass1e.<SetBackend>b__1d ()
RelationsInspector.RelationsInspectorWindow.Update ()
UnityEngine.Debug:LogException(Exception)
RelationsInspector.RelationsInspectorWindow:Update()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
Title: Re: A graph of inter-FSM events
Post by: seldomU on April 23, 2016, 11:57:21 AM
Ok, that's the same issue in another line. Are you getting that with the same scene? Fix attached.
Title: Re: A graph of inter-FSM events
Post by: rik on April 23, 2016, 12:30:36 PM
editor was too show now with many fsms
Title: Re: A graph of inter-FSM events
Post by: seldomU on April 23, 2016, 12:47:17 PM
In general the tool can handle more than 100 nodes just fine, but upwards of that it starts to slow down. With that many nodes the graph becomes unreadable anyway. I'll look into an option to hide FSMs that are not connected.
Title: Re: A graph of inter-FSM events
Post by: rik on April 23, 2016, 01:07:18 PM
i have 526 nodes
Title: Re: A graph of inter-FSM events
Post by: seldomU on April 23, 2016, 01:28:51 PM
Ok that's heavy :D

The attached version has an toolbar toggle to hide the unconnected nodes. Enable that before generating the graph. Of course it only helps if the majority of your nodes actually are unconnected. Otherwise I think only some kind of hierarchical graph would make your data accessible.

@mdotstrange: this version also adds support for all the Get/Set Fsm ... actions.
Title: Re: A graph of inter-FSM events
Post by: Alex Chouls on April 23, 2016, 04:50:33 PM
This looks like it's coming along nicely!

The next Playmaker update will include a callback for OnFsmChanged that you can hook into to update the graph...
Title: Re: A graph of inter-FSM events
Post by: dudebxl on April 24, 2016, 07:39:57 AM
WOW - super useful!!!
Title: Re: A graph of inter-FSM events
Post by: seldomU on April 24, 2016, 02:08:29 PM
@dudebxl: Thank you!

@Alex: Great, I'll build an auto-update option out of that.
Title: Re: A graph of inter-FSM events
Post by: seldomU on May 14, 2016, 06:08:13 AM
RelationsInspector update 1.1.2 has arrived on the AssetStore today, with the PlayMaker communication graph as part of its package. To celebrate the launch, the full version is 50% off for a short time. Get it here:
Documentation (https://seldomu.github.io/riBackends/PlayMakerFsmCommunicationBackend/)

Thank you guys for the feedback and suggestions!
Title: Re: A graph of inter-FSM events
Post by: seldomU on December 20, 2016, 06:00:25 AM
I have a few vouchers for the RelationsInspector full version to give away. If you want one, just let me know.
Title: Re: A graph of inter-FSM events
Post by: 4ppleseed on December 21, 2016, 04:15:50 AM
I have a few vouchers for the RelationsInspector full version to give away. If you want one, just let me know.

Yes please! This looks great  8)
Title: Re: A graph of inter-FSM events
Post by: clandestine on December 21, 2016, 06:59:30 AM
I have a few vouchers for the RelationsInspector full version to give away. If you want one, just let me know.

Hey that would be a great sauce for my tangled and dry FSM spaghetti :D
And i would be very grateful!
Title: Re: A graph of inter-FSM events
Post by: djaydino on December 21, 2016, 08:45:13 AM
I have a few vouchers for the RelationsInspector full version to give away. If you want one, just let me know.

That would be nice!
Title: Re: A graph of inter-FSM events
Post by: seldomU on December 21, 2016, 03:53:30 PM
You all got PMs  :)
Title: Re: A graph of inter-FSM events
Post by: djaydino on December 22, 2016, 01:38:04 AM
Hi,
Thx for the voucher.
As soon i have some time I will play around with it and review it (won't be this year anymore tho....to much work to do and family.)
Title: Re: A graph of inter-FSM events
Post by: clandestine on December 22, 2016, 02:11:46 AM
Hey seldomU, thank you for the Christmas gift!
Title: Re: A graph of inter-FSM events
Post by: seldomU on December 24, 2016, 04:01:00 AM
You're welcome :)
I'm out of vouchers now. For anyone else that's interested in RelationsInspector, there is still the free feature-complete demo here:
https://www.assetstore.unity3d.com/en/#!/content/54884
Title: Re: A graph of inter-FSM events
Post by: Champ on December 25, 2016, 07:34:22 PM
Thanks for the voucher SeldomU.

Looking forward to sitting down and checking this out in my next quiet time :]
Title: Re: A graph of inter-FSM events
Post by: human890209 on June 25, 2017, 12:40:47 AM
I've tested RI and found something not so cool.

1> The FSM Name is not displayed, so if ONE Gameobject got More than 1 FSM things will get confused.

2> If I set the Target GameObject Variable by a Result Variable from actions like Get Owner, Get Root, Find Gameobject, Get Event Info(Sender)... It only works during Runtime cause the target variable's value is None in Edit Mode. Also if the variable is None during Runtime it keep's hidden.

3> FSM using an FSM Template only works during Runtime.

So it is hard to display all the event and set/get-variable relationship of FSMs by RI.