| 43 | |
| 44 | == Triggers and on fly paths == |
| 45 | |
| 46 | Currently there is no way to run a cinema path without a trigger script, but this possibility will be added later. |
| 47 | |
| 48 | === Run cinema path === |
| 49 | |
| 50 | An example trigger script to run an existing cinema path in 5 seconds: |
| 51 | |
| 52 | {{{ |
| 53 | #!javascript |
| 54 | Trigger.prototype.StartCutscene = function(data) |
| 55 | { |
| 56 | var cmpCinemaManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_CinemaManager); |
| 57 | // We should work only with valid components |
| 58 | if (!cmpCinemaManager) |
| 59 | return; |
| 60 | // Add a cinema path with "test" name to the queue |
| 61 | cmpCinemaManager.AddCinemaPathToQueue("MyPath"); |
| 62 | // Start playing the queue |
| 63 | cmpCinemaManager.Play(); |
| 64 | }; |
| 65 | |
| 66 | var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); |
| 67 | cmpTrigger.DoAfterDelay(5000, "StartCutscene", {}); // Delay is set in milliseconds |
| 68 | }}} |
| 69 | |
| 70 | === Add cinema path in triggers === |
| 71 | |
| 72 | {{{ |
| 73 | #!javascript |
| 74 | Trigger.prototype.StartCutscene = function(data) |
| 75 | { |
| 76 | var cmpCinemaManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_CinemaManager); |
| 77 | // We should work only with valid components |
| 78 | if (!cmpCinemaManager) |
| 79 | return; |
| 80 | |
| 81 | let pointA = new Vector3D(1, 1, 1); |
| 82 | let pointB = new Vector3D(100, 100, 100); |
| 83 | let path = { |
| 84 | "name": "MyPath", |
| 85 | "orientation": "target", |
| 86 | "positionNodes": [ |
| 87 | {"deltaTime": 0, "position": pointA}, |
| 88 | {"deltaTime": 10, "position": pointB} |
| 89 | ], |
| 90 | "targetNodes": [ |
| 91 | {"deltaTime": 0, "position": Vector3D.add(pointA, new Vector3D(10, 10, 0))}, |
| 92 | {"deltaTime": 10, "position": Vector3D.add(pointB, new Vector3D(10, 10, 0))} |
| 93 | ] |
| 94 | }; |
| 95 | |
| 96 | // Add the newly created path |
| 97 | cmpCinemaManager.AddPath(path); |
| 98 | cmpCinemaManager.AddCinemaPathToQueue(path.name); |
| 99 | |
| 100 | // Start playing the queue |
| 101 | cmpCinemaManager.Play(); |
| 102 | }; |
| 103 | |
| 104 | var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); |
| 105 | cmpTrigger.DoAfterDelay(5000, "StartCutscene", {}); // Delay is set in milliseconds |
| 106 | }}} |