As the introduction to each scene would involve the player's ship falling from the sky and tumbling into the starting position.
I considered simply dropping the the ship from the sky and letting Unity's physics handle it, but it would be too unpredictable with regards to setting up the camera and the player's starting and ending position (especially as my original plan involved launching it at an random angle into the middle of the map).
Due to this I chose to physically simulate the ship falling in Maya, bake the animation, then import into Unity.
The first step was to recreate the terrain used in the level into Maya, there is no direct way of exporting it as a mesh, however you can export the heightmap from Unity and import it into Maya.
world1 terrain heightmap |
Then in the sculpt geometry tool settings the max displacement was set to the terrain's height (2048 units), the heightmap was imported through the Attribute Maps setting.
As the terrain didn't fully reach it's preset height, a minor amount of tweaking the vertical scale was required in order to get it to match the Unity terrain.
The terrain then needs to be reoriented to match the Unity terrain.
The terrain in Maya with wireframe overlaid |
It was preferable to have the ship already tumbling as it was falling from the sky. The easiest way to implement this was to simply have the proxy hit something on the way down like this:
The animation of the falling ship is then baked and a joint is created then positioned and parented to the ship object. The joints animation is then baked. The joint's animation is will provide the animation for the falling ship within Unity.
After refining the camera movement to give part of it a somewhat hand-held feel the Maya portion of the sequence was pretty much done:
The red box at the end of the sequence is to get the falling ship to stop sliding with a bit of jolt, rather than sliding to a stop or simply disabling the simulation. It could potentially be replaced with a rock or some other solid object in-game or merely left as a dramatic jolt.
After importing into Unity, the Maya scene is placed in the Unity scene as a Game Object (making sure it is placed at 0,0,0 in world space) and any unnecessary parts deleted, such as any proxy meshes, lights etc.
I have a prefab set up to be placed in each level of the game, which contains all the necessary Game Objects for the game to work, amongst other things this contains cameras set up to be used in cinematics with a Cinematic.cs script attached to parent them to the camera transforms present in the imported Maya scene. (The script also contains a line to rotate the camera by 270 degrees along the Y axis, as the look axis of cameras appears to differ between Maya and Unity).
There is also another GameController Game Object with a GameController.cs script attached which finds the cameras and also controls which one the player is currently looking through, as well as having variables to adjust the length of the cinematics.
Here is the cinematic as it appears in-game, with some rudimentary particle effects attached to the falling ship:
One thing I need to change with this is when the camera cuts, at present it uses just one camera that should move instantaneously from the first location to the second location, however it renders a few frames inbetween the two giving that awkward flicker you see. I'm not entirely sure if I can set it up to move instantly in Unity (it does in Maya), so I'll probably end up using a multiple camera setup. Which means changing my code.