0
\$\begingroup\$

I am making a story driven game right now, and I want to create a system that will allow me to code sequences easily without creating a mess from the project. What I mean by sequences is for something like a Scene, for example, since it's story driven, the player begin in a room, which then a character walk in, display a dialogue, then walks away, does a few things, a couple of sounds and effects are played, etc.

I was wondering how I could structure a system like that, that will allow me to have hundreds of this sequences without making a big mess of my project, also, these are going to be must like scripted, is it better to keep most of the scripts in a fewer class files or it's a good idea to spread them more? (to more class files)

I hope you can understand exactly what I meant and thank you in advance.

(I am making this in C# in Unity but I am not looking for specific code, just theory how to construct such system effectively)

\$\endgroup\$
1
\$\begingroup\$

You need a good folder structure and you should keep anything you can apart and structure it like a theater play. This way, the bugs will only ever be in the scene or the act and you can easily debug when it's needed.

Since your main mechanic is "storytelling", you won't have a repeatable gameplay loop. So, have a gameplay folder where you keep all the player's actions that are not scripted (i.e. controls, options) and keep the rest in a story folder where you structure it like "Act1, Act2..." and each act has scenes which are named "Scene1, Scene2...".

Let's say the player can interact with a desk, the desk and the script for the animation of the desk and the player while they're interacting will be in the corresponding scene folder, but the ability to interact with the object (press e to interact or the UI objects) will be in the gameplay folder.

For example:

  1. Player is in a room interacts with a character, character leaves room. Play sounds etc. End Scene.
  2. Some other stuff happens outside, another character walks in, there's a whole lot of things that happen. End Scene.
  3. Repeat scene process until you're satisfied with the story. End Act.

Now the folder structure will look a bit like this: enter image description here Repeat the process for other "acts" (Which should be your Unity scenes). For more info on this I'd suggest referring to William Shakespeare's theater plays.

Again, what I'm talking about here is not Unity scenes themselves but the scenes in an act of a theater play. You can make every single scene into a Unity scene but that would mean a whole lot of scene loading and unloading which might be a bit over the top (there's nothing wrong with doing it that way though).

\$\endgroup\$
0
\$\begingroup\$

You could use a generic state machine to organize when and what must interact. On a project I had a small narrative to implement so I create a state machine that handles the scripts which handled the gameobjects. You can have how many of these state machines you want but the asset will be on your folders as usual, the way you want them.

enter image description here

\$\endgroup\$
0
\$\begingroup\$

If i understand it correctly you mean that during the game, game objects are created and put in your hierarchy. if that is the case, then you only have to script something that will delete the game object after a certain time.

If this is not what you meant then please add more details to the question :)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.