Last week, I worked on the tutorial. It's time for Professor Meow!
As any tutorial, you simply follow a list of steps to be done in a specific order.
So at first I thought about programming the different steps, there are only a few:
- Move with drag
- Jump with right click
- Collect a jewel
- Enable a checkpoint
BUT.
You are free to move, so some steps can be skipped. The tutorial has to follow where you are and what you still have to do.
These constraints led me to use a Finite-State Machine (FSM).
After searching for an easy one for Unity, I finally decided to write my own.
Because the main problem I faced is that most FSM do not wait for tasks to be completed. Once you arrive in a node, they run the tasks and immediately test the conditions.
But I really had to wait for tasks to be completed first. (mainly because of text apparition)
A few hours later, I had a very basic system with nodes and links, all asynchronous and easy to use.
I also wrote a simple text loader so I could write the FSM in plain text.
Here is an extract of the tutorial FSM in plain text:
Text|Hi, I'm Professor Bartholo<colorful><swing>meow</>!\nI will teach you how to <shake><gradient_red>survive</>.
Wait|1
HasMovedEnough?
Text|Hmm you already know how to move.|SERIOUS
Wait|1
HasEnabledTutorialCheckpoint?
Text#end_proud|Ok you're way too fast for me now.
Wait|2
Text|I'm so proud of you! Good luck!|SERIOUS
Wait|2
TutorialDone
Hide
HasTakenTutorialJewel?
Text|You got the jewel. So what next?|NORMAL
Wait|1
HasEnabledTutorialCheckpoint?
...
Well, easy to write! And to read again later!
And it's actually very easy to add new nodes and new conditions!
There's no visual graph editor, but I'm considering it now if I have some time to write it.
I also decided to use this FSM to make some reactions of Professor Meow during the game (when you die, when you reach certain points, ...)
And here is the result: