Yeah, I was just giving a simpler examples of functions which can be called. But sometimes you won't have enough of predefined actions. So custom functions for them will be useful.
I like your ideas, thanks! Animation actions can be also used like this:
{
type = 'Animation',
target = 'sleepyDude',
animation = 'getting_up_from_bed',
waitUntilAnimationFinish = true
}
So the next action can immediately begin after the animation is set or wait until the animation finishes depending on
waitUntilAnimationFinish value.
Here's an example of a cutscene I've already done. This is very simple, and of course I could create "Print" action or something, but I'll just show the general principle.
local cutscene = {
{
f = function()
print("Hello")
end
},
{
type = CutsceneActionType.Delay,
finishTime = 1000
},
{
f = function()
print("World")
end
},
}
This cutscene prints "Hello", then waits for one second and then prints "World".
I have Cutscene class which has vector of pointers to
CutsceneActionI inherit from
CutsceneAction to create
DelayCutsceneAction which works the same as other actions which follow this principle at the moment:
1) Call
currentAction's function
2) If
currentAction->isFinished() then we can move on to another action
3) Else we update the
currentAction, just passing delta time to its
execute function
At this point it's easy to came up with idea how to implement
DelayCutsceneAction, so I won't post its code here.
I think this explanation may be a bit too short for such complex topic and I think I'll write an article about it once I have more experience with it (once I create complex cutscenes some things will change for sure)
But also keep content creators in mind who might not be programmers. They might have a far easier time to toy around with data in a tree that's displayed in a treeview control or something similar (think of the trigger editors for Blizzard's RTS games, like StarCraft (2)).
Good idea, maybe I'll make a GUI for cutscene editing at some point and then it will be easier to implement!
(And I also need to check out how cutscene creation works in Starcraft)