Triggering Cinematic on SceneLoad Event with IronPython Action Script

Tutorial: Triggering a Cinematic Sequence When the Scene Starts


 
In this tutorial we will see how to start a cinematic sequence at scene loading.
 
To do this we will create a new scene and we will record simple cinematic. We name cinematic сinematic1.
 
In more details about cinematic creation see «Cinematic Creation».
 
Then we drag and drop «Scene Load» event into the Design view of the scene. As soon as we will drag and drop the event, the new trigger with event «Scene Load» will be created. The trigger can be edited in World Explorer. We will rename it in “StartCinematic”.
 
Now we need to add something our trigger will do. It is possible to use two types of action - An action written in Python Scripting code and a predefined action you can find in Asset Explorer.
 
For Python Scripting action addition, drag and drop PythonAction from Asset Explorer onto the trigger. Double click it then to open the Script Editor. 
 
Add the following code:
 
PlayCinematic ("сinematic1")
 
The scripting function PlayCinematic plays back a cinematic sequence. We recorded the sequence сinematic1 earlier already. To test your new code, press the play button. It should work fine.

 

So, what is this magic all about? Visual3d uses the IronPython scripting language for scripting. IronPython is a recreation of the popular Python scripting language for use with the .net Framework. So the syntax for scripting in Visual3d.net equals Python syntax. 
How do I get an idea of the possible commands that can be executed? This might be another question you are asking yourself. In the code editor right click and select Snippets. This contains a list of commands and if you click on a command, it will automatically add the command using the right syntax for you. Let’s try that out. In the second code line right click and select Snippets->SSystem->ShowCaption. This will add
 
ShowCaption("text")
 
To the code. The ShowCaption command displays something like a status message for a few seconds and then automatically fades this out again. Change the text to something more interesting now:
 
ShowCaption(“, that is a lot of rotation!”)


 

Now press the Save button in script editor.
 
If you use the predefinded «PlayCinematic» component action, then you can just select a cinematic sequence in Object Editor. 
 
Save and reload a scene. At scene loading, the cinematic should be playing.