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!