playMaker

Author Topic: Generating states on a new FSM added to a game object  (Read 2252 times)

coaster

  • Playmaker Newbie
  • *
  • Posts: 7
Generating states on a new FSM added to a game object
« on: January 21, 2015, 04:26:03 PM »
I cannot seem to find out how I would go about generating an arbitrary number of FsmState objects for an FSM that was just created and added to a game object all through C#.  I was able to create them by adding the PlaymakerFSM object to the game object first then creating an array of FsmState objects and assigning that to the Fsm.  However when I go to move the states in the actual FSM in the Playmaker Editor, I receive an error for each mouse click when trying to move a state:

Code: [Select]
NullReferenceException: Object reference not set to an instance of an object
HutongGames.PlayMakerEditor.FsmGraphView.UpdateGraphBounds (Vector2 viewPos, Single padding)
HutongGames.PlayMakerEditor.FsmGraphView.HandleMouseUp ()
HutongGames.PlayMakerEditor.FsmGraphView.HandleMouseEvents ()
HutongGames.PlayMakerEditor.FsmGraphView.DoCanvasView ()
HutongGames.PlayMakerEditor.FsmGraphView.OnGUI (Rect area)
HutongGames.PlayMakerEditor.FsmEditor.OnGUI ()
FsmEditorWindow.DoGUI () (at Assets/3rdParty/PlayMaker/PlayMaker/Editor/FsmEditorWindow.cs:94)
HutongGames.PlayMakerEditor.BaseEditorWindow.OnGUI ()
System.Reflection.MonoMethod.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:222)

I tried setting a Rect position for each state before assigning the array into the Fsm but still got the same problem.  Any idea of what I am missing that Playmaker is saying is null that is required?
« Last Edit: January 21, 2015, 04:59:37 PM by coaster »

coaster

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Generating states on a new FSM added to a game object
« Reply #1 on: January 21, 2015, 04:54:34 PM »
Found solution, had nothing to do with setting initial position, although the states generate in the Playmaker Editor on top of each other.  I was not setting a start state, now I am able to move all of the states around in the editor with no error that were generated though.  Simple example:

Code: [Select]
Fsm fsm = playmakerFSM.Fsm;
fsm.StartState = "State 1";  // or whatever state(s) you create you want as Start
« Last Edit: January 21, 2015, 04:59:13 PM by coaster »