How to implent cut scenes?
by Alexander B · in Torque 3D Professional · 02/22/2010 (6:31 am) · 48 replies
I want to have cutscenes in my game. Not ingame cutscenes like what GMK and Verve does but acual pre-made cutscenes.
What I want to do is get the cutsecene in an ogg file, make a trigger that activates the cutscene ingame and if possible goes to the next mission or the main menu.
I relize that I will probaly have to use theora but I don't really understand it or how to use it.
What I want to do is get the cutsecene in an ogg file, make a trigger that activates the cutscene ingame and if possible goes to the next mission or the main menu.
I relize that I will probaly have to use theora but I don't really understand it or how to use it.
#2
02/22/2010 (8:54 am)
Thanks for ur reply but I'm still pretty confused. If you are able to talk to me on skype or msn that would be great. My msn is bruneman@hotmail.com and my skype is thecool444
#3
02/23/2010 (2:35 am)
Bump cuz its important.
#4
Unfortunately, I have too much on my plate to assist 1on1 in chats.
The steps above may sound complicated but this is in fact rather easy and takes only light scripting. Some experimentation will probably quickly get you there.
02/23/2010 (5:57 am)
Unfortunately, I have too much on my plate to assist 1on1 in chats.
The steps above may sound complicated but this is in fact rather easy and takes only light scripting. Some experimentation will probably quickly get you there.
#5
I have no idea how to do step 3,4 and 5. Chat will be much faster and I won't bug you much i promise XD.
I just need to get this all implented really quickly as my game is due for release next month. If you still can't talk to me over IM is there any other documentation for theroa or something that could get me set up quickly.
Anyway thanks for your time and hopefully It will all work out :)
02/23/2010 (6:48 am)
Ok then, bassically I am using theora goodies to convert it to ogg but it has no sound. Do I use vorbis to get sound for it or something?I have no idea how to do step 3,4 and 5. Chat will be much faster and I won't bug you much i promise XD.
I just need to get this all implented really quickly as my game is due for release next month. If you still can't talk to me over IM is there any other documentation for theroa or something that could get me set up quickly.
Anyway thanks for your time and hopefully It will all work out :)
#6
02/23/2010 (7:14 am)
I was under the impression that theroa was broken and not working for video playback. If it works ill research the class more and try and get a tutorial working.
#7
02/23/2010 (7:59 am)
I've tested out Theora in lastest T3D and it's working fine.
#8
2) Create a new Gui called "CutsceneGui" in the Gui Editor using GuiControl as the topmost control. Place a GuiTheoraCtrl on the control and set its internalName to "video".
3)
4)
Hope this clears this up a little.
//Edit: fix
02/23/2010 (9:38 am)
1) Better use VLC or some other quality encoder. Go from uncompressed to Theora if possible. Make sure to have Vorbis-encoded audio.2) Create a new Gui called "CutsceneGui" in the Gui Editor using GuiControl as the topmost control. Place a GuiTheoraCtrl on the control and set its internalName to "video".
3)
function startCutscene( %theoraFile )
{
// Stop game.
disconnect();
// Set video file to play.
CutsceneGui->video.theoraFile = %theoraFile;
CutsceneGui->video.playOnWake = true;
// Put up CutsceneGui.
Canvas.setContent( CutsceneGui );
schedule( 10, 0, "checkCutsceneFinished" );
}4)
function checkCutsceneFinished()
{
if( CutsceneGui->video.isPlaybackDone() )
/* do what is supposed to happen after cutscene has played */;
else
schedule( 10, 0, "checkCutsceneFinished" );
}Hope this clears this up a little.
//Edit: fix
#9
1. For steps 3 and 4 do I just create a new script called theora.cs and put that code in there, or do i put it in an already existing script?
2. How do I use it ingame? Trigger or something else?
02/23/2010 (12:53 pm)
Thanks for that but I still have 2 questions:1. For steps 3 and 4 do I just create a new script called theora.cs and put that code in there, or do i put it in an already existing script?
2. How do I use it ingame? Trigger or something else?
#10
1. You have a lot of options there. One way you could do it is to put it in the same file that you put CutsceneGui into. For example, save CutsceneGui to art/gui/cutsceneGui.gui and then put the code after //-- OBJECT WRITE END ---. Also add
to the initClient() function in scripts/client/init.cs (e.g. after startupGui.gui is exec'd).
2. This depends on how you want it to work. Trigger is one possibility. Basically, you need to determine all events that may lead to the cutscene being played and then hook up the logic to all these events.
Also, be aware of what you want you game to do. Do you want it to exit the mission? Then the code above is fine. Do you want the mission to pause? Then the disconnect above needs to go and you need to pause simulation.
But yeah, a trigger is definitely a nice and easy way to test it.
02/23/2010 (12:59 pm)
1. You have a lot of options there. One way you could do it is to put it in the same file that you put CutsceneGui into. For example, save CutsceneGui to art/gui/cutsceneGui.gui and then put the code after //-- OBJECT WRITE END ---. Also add
exec( "art/gui/cutsceneGui.gui" );
to the initClient() function in scripts/client/init.cs (e.g. after startupGui.gui is exec'd).
2. This depends on how you want it to work. Trigger is one possibility. Basically, you need to determine all events that may lead to the cutscene being played and then hook up the logic to all these events.
Also, be aware of what you want you game to do. Do you want it to exit the mission? Then the code above is fine. Do you want the mission to pause? Then the disconnect above needs to go and you need to pause simulation.
But yeah, a trigger is definitely a nice and easy way to test it.
#11
02/24/2010 (12:07 am)
Thanks for that, so far so good but I don't know what to do for the trigger. What trigger type would I use and what would I tell it to do?
#12
There are -> on torquescript now?
(Sorry if this has been mentioned elsewhere already)
02/24/2010 (5:34 am)
@Rene, sorry for the side-topic, but whats that on CutsceneGui->video.theoraFile = %theoraFile; CutsceneGui->video.playOnWake = true;
There are -> on torquescript now?
(Sorry if this has been mentioned elsewhere already)
#13
Just a regular trigger found under "Library -> Level". Create your own TriggerData in the Datablock Editor and define an "onEnterTrigger" method for that datablock object in script (just put it alongside the TriggerData in managedDatablocks.cs). Look at the DefaultTrigger method definitions in the scripts for an example. In the "onEnterTrigger" method, put the cutscene activation code.
//---
//Edit: BTW, it's usually best to not trigger huge world changes from within callbacks. In these cases, simply schedule() the respective functions so they execute from toplevel.
//---
@Novack
Yep, there's two operators there for looking up objects by their internal names:
This is a great feature that removes a lot of the need for globally naming your objects.
02/24/2010 (9:59 am)
@AlexanderJust a regular trigger found under "Library -> Level". Create your own TriggerData in the Datablock Editor and define an "onEnterTrigger" method for that datablock object in script (just put it alongside the TriggerData in managedDatablocks.cs). Look at the DefaultTrigger method definitions in the scripts for an example. In the "onEnterTrigger" method, put the cutscene activation code.
//---
//Edit: BTW, it's usually best to not trigger huge world changes from within callbacks. In these cases, simply schedule() the respective functions so they execute from toplevel.
//---
@Novack
Yep, there's two operators there for looking up objects by their internal names:
// Look up 'ChildObject' by internalName as direct child of %obj: %obj->ChildObject; // Recursively look up 'ChildObject' by internalName as direct or indirect child of %obj: %obj-->ChildObject;
This is a great feature that removes a lot of the need for globally naming your objects.
#14
Looking forward to see all this new gems documented.
02/24/2010 (10:09 am)
Wow, interesting. thanks Rene!Looking forward to see all this new gems documented.
#15
02/24/2010 (12:32 pm)
Ok, I sorta understand what you mean, but if its ok can you give me an example trigger function I could use? If not, please tell me what my cutscene activation code is.
#16
2) Save the datablock. Open managedDatablocks.cs and add a function
3) Create a Trigger object in your game and assign "CutsceneTriggerData" to its datablock property.
If you exit the editor now and run into the trigger with the player, the game should exit and the cutscene should start to play.
02/24/2010 (12:58 pm)
1) Create a TriggerData datablock in the Datablock Editor. Call it 'CutsceneTriggerData'.2) Save the datablock. Open managedDatablocks.cs and add a function
function CutsceneTriggerData::onEnterTrigger( %this, %trigger, %obj )
{
// Schedule execution of cutscene playback of the given Theora video file.
schedule( 1, 0, "startCutscene", "path/to/myTheoraVideoFile.ogv" );
}3) Create a Trigger object in your game and assign "CutsceneTriggerData" to its datablock property.
If you exit the editor now and run into the trigger with the player, the game should exit and the cutscene should start to play.
#17
02/24/2010 (1:03 pm)
Ok, will test tonight. Thanks and hopefully this is my last question. I already have a trigger set up on each mission that loads the next mission. As soon as the cutscene is finished, I want it to load either the next mission or next trigger that loads the next mission so whatever I do does essentially the same thing.
#18
You can put the chaining in the function that checks for video playback having finished:
02/24/2010 (2:11 pm)
You can put the chaining in the function that checks for video playback having finished:
function checkCutsceneFinished()
{
if( CutsceneGui->video.isPlaybackDone() )
StartLevel( "levels/MyNextLevel.mis" );
else
schedule( 10, 0, "checkCutsceneFinished" );
}
#19
Everything else seems pretty simple to do tho so once thats out of the way I should go through the rest pretty quick. Once again thanks for your help :)
02/24/2010 (10:22 pm)
Sorry for going back a bit but with the GUI what do you mean by: Place a GuiTheoraCtrl on the controlEverything else seems pretty simple to do tho so once thats out of the way I should go through the rest pretty quick. Once again thanks for your help :)
#20
Are you saying audio works now?
If so I will be quite happy!
02/25/2010 (2:40 pm)
I had tried Theora in T3D and only the video worked, not the audio.Are you saying audio works now?
If so I will be quite happy!
Associate Rene Damm
2) Create a separate fullscreen cutscene GUI with a GuiTheoraCtrl on it (let's name it CutsceneGui here). Set playOnWake=true.
3) When going from game to cutscene, replace the GUI (PlayGui) with CutsceneGui. If you want to resume gameplay after the cutscene, only pause the game and replace only the gui. If you want to stop the game, disconnect first:
4) After the cutscene has played (use a scheduled check), resume the game or move on to the next mission or MainMenuGui.