Game Development Reference
In-Depth Information
How to do it...
So now that we have a scene prepared with some waypoints we can get to work with im-
plementing the cutscene itself by performing the following steps:
1. We start by loading a scene where the Cinematic will be played out. The scene
reference will be used in several places, so it is a good idea to store it in a field.
2. We'll also create a Spatial field called Jaime, the main actor and either load or
extract him from the scene (depending on the setup).
3. Now, we can create a MotionPath instance called jaimePath for Jaime. Since
we created Nodes for each waypoint in SceneComposer , we can get their loca-
tion from the scene by using:
jaimePath.addWayPoint(scene.getChild("WayPoint1").getWorldTranslation());
4. We go on and create a MotionEvent called jaimeMotionEvent using
jaimePath and initialDuration of 25 seconds:
jaimeMotionEvent = new MotionEvent(jaime, jaimePath,
25f);
5. It's also preferable if Jaime faces in the direction of the path he travels along, so we
also set directionType to MotionEvent.Direction.Path .
Before we get too far, we want to check out that the path Jaime follows is alright. There-
fore, we should go ahead and create a Cinematic instance at this point. To do this, per-
form the following steps:
1. Doing this is as simple as supplying it with a scene, which will affect rootNode
together with the total duration of the cinematic:
cinematic = new Cinematic(scene, 60f);
2. After that, we add MotionEvent with the following line; 0 being the time it
should start at:
cinematic.addCinematicEvent(0, jaimeMotionEvent);
3. We also need to add cinematic to the stateManager of the application with
stateManager.attach(cinematic) .
Search WWH ::




Custom Search