Brian Crick

Travel, Without Moving

One of the more technically complex sequences in Tinselfly involves your 175 meter long, 285 meter tall spaceship flying into a spaceport where the player can board it, and leave immediately with the player on it, with no loading screens or interruption to player control.

This was challenging to implement because the ship can’t move.

As far as the Unity game engine I’m using is concerned, the ship — where you’ll spend much of your time in game — is a static scene, meaning that there’s pre-calculated lighting and visibility and pathfinding information encoded into the scene that makes the game run faster and better… and if the elements of the scene were to move, that information would become invalid. Lights wouldn’t illuminate the areas they’re supposed to, NPCs wouldn’t be able to move around, and the various calculations that determine what the player can see would stop providing accurate results.

To solve this problem, I’m using multiple cameras: one for the spaceport, and one for the ship. The spaceport camera is attached to the player’s head; no surprises there. But as the player moves through the spaceport, and as the ship ‘moves’ through the scene, the ship camera moves to the position you’d see the ship from, given the spaceport camera location and ship location.

(Sometimes, it seems like half of the codebase for Tinselfly in converting things from one coordinate system to another, but that’s another topic.)

Just syncing up the cameras isn’t enough to sell the illusion, though. The ship needs to appear to pick up light from inside the spaceport: it should be affected by fog, be bathed in some purple bounce light from the spaceport walls, and the glassy sails should appear to reflect the buildings and signs around you.

As far as Unity is concerned, none of the light is actually pre-calculated in the scene with the ship, so it all has to be faked. Enter custom shaders.

(Sometimes, is seems like the other half of Tinselfly’s codebase is custom shaders…)

A shader is a little program that tells Unity how to draw something on screen, what color it is, how bumpy the surface is, how it reacts to light. In this case, the hull of the ship has custom shaders that calculate the reflection angles you’d get if the ship were really where it appears to be, and add the aforementioned fog and reflections. Also, there’s a gigantic, invisible purple light outside of the ship, that turns on just when it’s in the spaceport.

Once the player boards the ship, they teleport from the spaceport scene to the ship scene, and the camera control reverses: the ship camera becomes attached to the player’s head, and the spaceport camera’s position becomes dictated by the ship camera and ship position.

Overall, I think the effect is fairly convincing. And it’s not something I’ve seen it a lot of games. I’d say I hope that rarity makes this sequence all the more memorable, but in the end, the goal here is to make it looks like there are no effects at all, and have the scene be memorable because of the narrative context in which you’re experiencing it.

Copyright © 2017 Brian Crick.