Search Instagram Twitter Facebook Spotify Grid Tag Date Folder Chat Pencil

DevLog Update – Objects Through Portals

I started working on how to teleport objects across while the player is carrying them. It turned out to be not as difficult as I had imagine. I was, however, getting this particular problem:

portal_glitch

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. 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, and attached a cube object to the player, also with the collider and other scripts removed (so that only the renderer remained). Let’s call this the “Mirror Image”. Then, whenever the player was within the 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 second where the actual cube disappears behind the render texture, the mirror image cube fills in the gap.

Here’s what it looks like:

portal_smooth

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.