Now I Seem To Be Thinking With Portals

Following on from "O Captain! My Captain!" that I made for Ludum Dare 46, I've been hard at work pulling the project apart, refactoring the code and experimenting with new concepts. On the art side, I've been getting into AssetForge, a kit bash tool with a few hundred assets in it, which is a definite improvement over Blocks. I'm still trying it out and am always on the lookout for other one-step-above-programmer-art tools.

In terms of code, there's a big problem with O Captain jam edition, and vehicle games in general, in that most game engines are built for fixed size levels of about +/-2000m in each dimension. This is due to the limited precision of floating-point numbers, where the difference between 0.001 and 0.002 (which could be relevant when making a model of a control panel) gets completely swamped when added to your ship's position at +4000 units. This causes textures to jitter and at extreme lengths can start making player movement jittery and unpleasant.

The other downside of using a moving platform in Unity is that the default components like CharacterController and Rigidbody are all simulated in world co-ordinates. What does CharacterController.Move(3, 4) mean when your ship is hurtling through space at 500 units per second in the opposite direction?

I've attempted a fix for this before by rendering an internal and external camera and layering them over each other, but that was for a potential VR game project and there was no need for the player to ever exit the ship. This time, I need a door that opens onto the world and a ramp that the player can climb up to enter the ship's interior. For this, we will need portals. 

Fortunately, I happen to have recently come across a great video by Sebastian Lague that delves deep into the realm of portals and even provides code samples of how to implement them in Unity. After watching the video through a couple of times and picking at the samples, I was able to assemble the following scene (I would recommend only looking at one bit at a time, I was quite liberal in just recording every possible camera)


There are still some jumps when teleporting (seems to be Unity's Update vs FixedUpdate problem yet again) and I need to work out how these windows are going to fit into my ship design. Spoiler alert: there will probably be more inside the ship than could feasibly fit in a Euclidean space.

Comments

Popular posts from this blog

Is Me!

Something's Brewing in the Tentacle Zone

Ludum Dare 46 - O Captain! My Captain!