• Register

Manifold Garden (previously known as Relativity) is an exploration-puzzle game that imagines a universe with a different set of physical laws. Set in an Escher-esque world filled with secrets and mysteries, you utilize a unique gravity-manipulation mechanic to turn walls into floors. Learn to see the world through whole new perspectives as you navigate mindboggling architecture and solve seemingly impossible puzzles. Manifold Garden is being designed and developed by William Chyr, and is intended to be released on PC and PS4.

Post news Report RSS Development Update - Smooth Portal Transition

Finally figured out how to create a smooth transition while carrying an object through a portal. Here's how I did it.

Posted by on

For the past few days, I've been polishing the portals in Relativity, and adding features to them. In addition to having the player move between portals, I also wanted the player to be able to carry objects with them. Getting the basics of teleporting both the player and the objects wasn't so difficult. I was, however, getting this particular problem:


As you can see, the cube that the player is carrying would disappear for a second while going through the portal. The reason why this was happening was because at that moment, the cube hasn't been teleported yet, and is behind the render texture, which is showing the other scene. Teleportation doesn't occur until the player hits the render texture.

I tried a bunch of different techniques to fix the problem, such as teleporting the cube
first, but all without much success. Eventually though, I remember reading somewhere that to get the physics of objects going through portals right in Portal, Valve would actually duplicate an object on the other side of the portal.

This gave me an idea.

I duplicated the player game object, removed all the controller scripts, camera, and colliders, so that only the renderer remained. I then attached a cube object to this empty player, also with is collider and scripts removed. Let's call this the "Mirror Image".

Then, whenever the player was within a specific zone in one portal, I would activate the mirror image in the other portal, with the same local position and rotation as the player. And so, in the split second where the actual cube disappears behind the render texture, the mirror image cube fills in the gap.

Here's what it looks like:


Post comment Comments
KITATUS
KITATUS - - 61 comments

Great read! Thanks for posting!

Reply Good karma Bad karma+2 votes
williamchyr Author
williamchyr - - 38 comments

Thanks! I totally benefited from Valve talking about the tech behind their portals, so thought I'd to the same. It's also a pretty clever solution, if I do say so myself :)

Reply Good karma+4 votes
KITATUS
KITATUS - - 61 comments

Very clever. In words it sounds so simple but I can guess that the initial implementation was far from simple?

Reply Good karma Bad karma+2 votes
williamchyr Author
williamchyr - - 38 comments

Ya, it was super confusing. Especially because you'd have one portal referencing the other. For example, if Portal A and Portal B are connected, and you're in Portal A, I need the mirror image to appear in Portal B. In the code, I'd refer to the other portal as sisterPortal, and there was a lot of sisterPortal of sisterPortal stuff going on back and forth.

Reply Good karma+2 votes
KITATUS
KITATUS - - 61 comments

Ah man! Glad you got there though, this post is gonna help a lot of people who may need object-friendly portals in their current / future projects.

Reply Good karma Bad karma+2 votes
e_Glyde
e_Glyde - - 331 comments

Superb work.

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: