Yesterday and today I spent the time making a cutscene system. I’m really proud of the result and thought other might also benefit from it. You can find the content here and a demo place to take a look for yourself here.
Below is a big overview of how exactly the cutscene system works (no tl;dr available). If you have any questions, find any bugs or if you have any suggestions let me know. I might not add the features or fix the bugs if I don’t think it’s important enough, but that of course doesn’t mean that I won’t allow you to do it yourself! And finally, some of the code in the cutscene system might not be perfectly clean or perfectly follow the standards of programming in Lua but oh well, I tried. ¯\_(ツ) _/¯
Overview
Parenting
Creating a cutscene
Scene.NewScene(string Name)
Scene.NewComponent()
You will want to create a new Scene object with Scene.NewScene() which will then return a Scene object. You can then create new Components to add to the Scene. Scene.NewComponent() will return a new object with a lot of properties (see the ModuleScript for specifics). You can add those components to the Scene object with Scene:AddComponent(component object). Components are added in order, so the first component you add with Scene:AddComponent() will be seen by the cutscene system as ‘Component 1’.
If you want to start a cutscene all you have to do is fire the Cutscene.API.RunScene BindableEvent with a Scene object as the first argument and an optional second argument which is an integer that indicates which Component should be displayed first.
Events
Features
I won’t give any example of how you can use every single feature as that would take too long and you can take a look at the place I linked at the start for it. I’ll instead just describe each feature and what you can do with it.
Dialog
One of the most exciting features of the dialog - in my opinion at least - is the response system. You can choose to display just dialog for X seconds before transitioning to the next component or you can add responses to dialog. The system allows up to 4 answer options. You can pick per answer which component will be shown after the player chooses that answer. Additionally, you can set a timeout on the responses. If you player doesn’t pick an option within the time the cutscene system will then jump to a component you picked beforehand.
Transitions
Actions
Notes
-
The cutscene system will disable the ‘Dead’ HumanoidStateType to prevent players from resetting during a cutscene. If they reset anyways it will only take effect after the cutscene has ended.
-
The cutscene system works on PC and XBox and probably also on mobile devices (although I haven’t tested it for those). The system will also respect (un)plugging an XBox controller and automatically adjust the UI for it.
Known issues
The default ControlScript uses ContextActionService to bind the ButtonA from the XBox controller to jumping. This cutscene system however tries to bind ButtonA to dialog options, so the ControlScript ends up overriding this 99% of the time. If you want to use this system it’s recommended to edit the ControlScript so you can easily unbind and rebind the ButtonA KeyCode.