playMaker

Author Topic: Why is state entered second time?  (Read 2260 times)

Apprentice

  • Playmaker Newbie
  • *
  • Posts: 3
Why is state entered second time?
« on: December 30, 2012, 11:41:57 PM »
Just try to use PlayMaker intensively these days, so I have to say that I am an absolute beginner to PlayMaker. The issue I have while I try to send event and receive event to do something is that the state will be entered twice for no apparent reason. The state that executes twice is always the last state of the chain. The image attached shows this issue.

It is still possible to always make the last state "do-nothing state", so even when it repeats twice, it won't have any impact. However, when any state that "send event" to other FSM, this particular state will be entered twice and there is no way I can do to avoid it.

Please help. Without knowing what's wrong with my usage, I couldn't keep using it as the event passing, handling is the key of the current game logic design. Thanks.


Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Why is state entered second time?
« Reply #1 on: December 31, 2012, 12:22:40 AM »
Hi,

I'm not seeing that behaviour here...

Could something be disabling/enabling the GameObject that owns the FSM?

What version of Playmaker are you using?

Cheers,
Alex

Apprentice

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Why is state entered second time?
« Reply #2 on: December 31, 2012, 04:07:48 AM »
The version I use, from "About PlayMaker", is 1.4.4f3. And Unity version I use is 4.0.0f7.

I am still finding out why this misbehavior occurs.

Don't know if the issue related to the error I get some time after I start to create lots of FSMs and states. The error showing in the debug window like the following.

ArgumentException: An element with the same key already exists in the dictionary.
System.Collections.Generic.Dictionary`2[System.Type,UnityEngine.Object].Add (System.Type key, UnityEngine.Object value) (at /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:404)
HutongGames.PlayMakerEditor.FsmEditorUtility.BuildActionScriptLookup ()
HutongGames.PlayMakerEditor.FsmEditorUtility.BuildActionsList ()
HutongGames.PlayMakerEditor.FsmEditorUtility.get_Actionslist ()
HutongGames.PlayMakerEditor.ActionSelector.BuildFilteredList ()
HutongGames.PlayMakerEditor.ActionSelector.OnFocus ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj)
UnityEditor.HostView.Invoke (System.String methodName)
UnityEditor.HostView.RegisterSelectedPane ()
UnityEditor.HostView.OnEnable ()
UnityEditor.DockArea.OnEnable ()


Apprentice

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Why is state entered second time?
« Reply #3 on: January 01, 2013, 03:33:02 AM »
Update for the issue.

The exception seems to have no impact on the outcome, it does not cause any harm(for now).

The problem that I posted seems to be solved by the proper use of Send Event. The background context which does not include in my previous post is that there is another FSM that in one state, I send one event to several other FSMs. The action I use is Send Event and the delay is set to 0 in all send event action. Although I have not done the complete test, I think the problem is that delay value.

I guess, the event with the send delay value to 0 is sent to different FSM in the same frame. When one particular FSM(B) receives the event and send event to other FSM(C), this makes the event system a bit unexpected. Well, I am still not sure if the state reentry second time issue is due to this event sending misuse, I just know after adjusting the delay value to 0.05, 0.1, 0.15 and so on to different FSM, everything starts to work as expected.

I hope this adjustment is correct and if it is documented some where, I apologize for not reading it first. Anyway thanks for this great product, it really helps a lot.  :)