playMaker

Author Topic: Sub-State-Machines - Missions - Code Review [Video]  (Read 2584 times)

Proton

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
    • NPlay
Sub-State-Machines - Missions - Code Review [Video]
« on: July 24, 2011, 01:23:00 AM »
I tried making a few videos to show how I am experimenting with PlayMaker 1.1. This video worked out okay I think.

I haven't been able to make complex machines, but am starting to find ways to connect smaller ones to do simple tasks.

Probably best to watch in 1080p

justifun

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 227
    • View Profile
Re: Sub-State-Machines - Missions - Code Review [Video]
« Reply #1 on: July 25, 2011, 10:23:40 PM »
Are you making temporary fsm's in order to optimize some how?

I'm not sure why you went to all the trouble to create and destroy them when you can do it easier without having to do that.

Proton

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
    • NPlay
Re: Sub-State-Machines - Missions - Code Review [Video]
« Reply #2 on: July 25, 2011, 11:49:57 PM »
I wanted to find a way to re-use state machines while keeping the prefab connection. Since we don't have nested prefabs in Unity, this was the best I could come up with.

Originally the dialog was done differently, I had one 'YesNoDialog' GO that was always in the scene and would just get activated/deactivated. This actually worked okay when the mission  FSM was also in the scene. But became uglier when the mission became a prefab.

The 'Move To Waypoint' and 'Look At Waypoint' FSM prefabs would be used by quite a few missions. So the main goal was to make sure that if I found a bug or wanted to change how the worked, that it could be done in one place and automatically update all uses.

So if the missions aren't prefabs, but always live in the scene then there are 2 different options I can think of:

Option 1
Hiearchy
- Dialogs
-- FSM_YesNoDialog
- Missions
-- FSM_Tutorial
-- FSM_Encounter Farpoint

In this case, any time a yes/no dialog is needed, the one in the scene is directly referenced and it does not need to be a prefab. The text is set on it, and it is activated then perhaps a global event could be listened for, or the polling for state method.
One limitation is you can only ever have 1 at a time.

Option 2
Hiearchy
- Missions
-- FSM_Tutorial
--- FSM_YesNoDialog_InvertControls (Prefab)
--- FSM_YesNoDialog_RetryTutorial (Prefab)
-- FSM_Encounter Farpoint
--- FSM_YesNoDialog_SaveColony (Prefab)

In this case, the dialog is a prefab. Since the missions are not prefabs, the dialogs can keep the prefab connection.
This allows for multiple yes/no dialogs to exist at the same time. Not very useful for a dialog, but not sure if  it would be useful for some other kind of FSM.

Perhaps in this case, it is better to not have the missions as prefabs.

It's quite possible I am making this unnecessarily complex, I want to try stress testing it so I can see how it would fit into my existing game. My current game is multiplayer, so the players do not exist in the scene until they join the game, so I store them as prefabs. I would like to have their weapon logic and the switching between weapons to be controlled by playmaker FSMs since my hand coded ones are a pain in the ass to maintain.