cutscene system

Hey,
I am currently working on an architecture for a cutscene / story system.
The goal is to make a system of characters that hold a story-controlling actions I can call in any order and execute a cutscene.
For example:

Public Character c1;
Public Character c2;

void story()
{
c1.say("hey");
c1.goTo(vector3);
c1.lookTo(c2);
c1.say("bye!");
}

In order to execute the functions one after the other, I found 3 possible ways:

  • Coroutines
  • Jobs
  • Static Queue
    Jobs seems too over-engineering for a feature that should probably run on the main thread,
    So the debate is mostly between coroutines and a queue.

In coroutines I could have the story function be a coroutine, and have the character action functions getting executed one after the other.
the problem is that it takes a lot of regular Unity functionalities such as Lerps and time.deltatime.

In a Queue I could have a queue of delegates that hold character actions, then when calling each character to make their action, They won’t perform an action but instead add a new action to the queue.
And every frame I would call from a storyManager: update() { _currentAction.execute(); }
If it returns true I can continue to the next action, if false I will call the same action in the next frame.
What do you think?
Are there any better strategies to achieve this?
Thanks!

A cutscene is a sequence of actions on one or more objects. Basically the same as non-interactive visual storytelling … some call them movies.

Guess what? Unity already has a system for that! :wink:

It‘s called Timeline. Can be nicely combined with Cinemachine for the camera work.

If you do want to make it yourself: Jobs are the wrong tool. Coroutines are just going to make things more complicated, you can keep track of time yourself in Update and implement a sequence of actions that run at a given time either once or until stopped. You really only need a list of timestamped actions. And an editor with a scrubbing tool because you don‘t want to fiddle with numbers and then restart. Like i said: Timeline is the tool for the job here.

Hi,

As mentioned here, the only thing you need to update regularly is time signature.
Events are called on event happen, for a timeline, when time >= targetTime.
Have needed functions in separated scripts/objects and make a start action call.
Alternatively you can have an event trigger when an action is done. and trigger some other acction.
It’s pretty much making an automatic gameplay.