• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Branching Cutscenes

atma505

Member
So I'm going off of FriendlyCosmonaut's cutscene tutorials (YouTube link), which work great. They build a cutscene object out of an array of scripts which is established in the trigger object's Creation Code.

This only covers cutscenes which progress in a linear manner though. What I'm looking to do is to have a cutscene go one of multiple different ways, depending on the player's input. For example, if during a cutscene an NPC says "The exit is this way, please follow me," I'd want two different paths for if the player chooses "yes" or "no."

I considered a few methods like 2D cutscene arrays, or by somehow skipping to certain points in the array using a variable in obj_cutscene. The former I'm not sure how to approach and the latter (see screenshot below) seems very limiting. Has anyone implemented something like this successfully in their game?

gms branching cutscene.png
 

TheouAegis

Member
Are you indexing each element of the cutscene with a variable that counts up every time a scene ends? What I would do is essentially just branching that index. In other words, the default value is if you assume the player is going to ignore conversations and just keep pressing whatever key or button moves the dialogue along, and that would be be straight dialogue tree where you just keep increasing the index variable. The 'no' choice would branch the index to a different value. So if your default cutscene has, let's say, 20 scenes in it, then index 20 would be for the player says 'no' at the first choice he comes across. And if a choice further down the no branch would take you back to the main dialogue tree, just index back to the main dialogue. But yes you would need a way to tell the program when it is simply showing a message and when it is waiting for a response. Those would be two different scripts that you would call.
 

phantogast

Member
I'd do this by having several separate linear cutscenes and then chaining them together as you need them.
ie, instead of putting it all in t_scene_info, set them up like this;
t_scene_dave_asks_player_if_theyre_hungry = [cutscenedata blah stuff];
t_scene_player_says_they_are_hungry = [cutscenedata blah stuff];
t_scene_player_says_they_are_not_hungry = [cutscenedata blah stuff];


And then when you get the player's input you just play the next appropriate scene. The input stage could literally just be an array like
[["yes", t_scene_player_says_they_are_hungry],["no",_scene_player_says_they_are_not_hungry]]
at the end of your first "ask" cutscene.

so at the end of t_scene_dave_asks_player_if_theyre_hungry, if player says "yes" then play t_scene_player_says_they_are_hungry.

You can keep it all in the same nested list if you want, it's possible but it will cause headaches when it goes wrong. Having an actual name of each section helps make sense of it and makes it a lot easier to organise, and makes it harder to screw up when you're creating lots of content.

imo! :D
 

atma505

Member
Are you indexing each element of the cutscene with a variable that counts up every time a scene ends? What I would do is essentially just branching that index. In other words, the default value is if you assume the player is going to ignore conversations and just keep pressing whatever key or button moves the dialogue along, and that would be be straight dialogue tree where you just keep increasing the index variable. The 'no' choice would branch the index to a different value. So if your default cutscene has, let's say, 20 scenes in it, then index 20 would be for the player says 'no' at the first choice he comes across. And if a choice further down the no branch would take you back to the main dialogue tree, just index back to the main dialogue. But yes you would need a way to tell the program when it is simply showing a message and when it is waiting for a response. Those would be two different scripts that you would call.
It sounds so obvious now that it's written out šŸ˜ OK, I implemented a 2D array so that each dialogue choice is attached to a number, i.e.
GML:
[Choice, ["Yes", 1], ["No", 2]]
... and I made t_scene_info an array. The Choice() script resets the scene counter and sets the "branch" variable in obj_cutscene, which determines what set of scripts is being performed.
2gms branching cutscene.png

I'd do this by having several separate linear cutscenes and then chaining them together as you need them.
ie, instead of putting it all in t_scene_info, set them up like this;
t_scene_dave_asks_player_if_theyre_hungry = [cutscenedata blah stuff];
t_scene_player_says_they_are_hungry = [cutscenedata blah stuff];
t_scene_player_says_they_are_not_hungry = [cutscenedata blah stuff];


And then when you get the player's input you just play the next appropriate scene. The input stage could literally just be an array like
[["yes", t_scene_player_says_they_are_hungry],["no",_scene_player_says_they_are_not_hungry]]
at the end of your first "ask" cutscene.

so at the end of t_scene_dave_asks_player_if_theyre_hungry, if player says "yes" then play t_scene_player_says_they_are_hungry.

You can keep it all in the same nested list if you want, it's possible but it will cause headaches when it goes wrong. Having an actual name of each section helps make sense of it and makes it a lot easier to organise, and makes it harder to screw up when you're creating lots of content.

imo! :D
I could combine the above technique with macros which would make it easier to navigate.
The worry I have now is that a potential conversation with multiple, basic Yes/No answers could get really convoluted. I'll go with what I have for the time being and see how it works, and if it gets tricky down the line then I'll have to get creative. Thanks for the help so far!
 
Top