Sunday, May 27, 2018

Teleporters and Portals

This post will be a short break from my procedural cities series. I found this Introduction to Game Development video presentation on the making of Portal and Portal 2 very interesting. I decided that I wanted to make the teleporters in 3DWorld into portals that the player could see through. This way, you can look through the teleporter to see if it's safe on the other side before stepping through. I used a separate rendering pass to create a texture that's drawn on top of the teleporter graphics when the player is close. It uses the same view direction and parameters as the player camera, but the camera origin is placed at teleporter destination location. Here is a screenshot of a teleporter that leads to the roof of the office building.

Teleporter with nested portal image reflected in the floor.

Yes, I made the portal rendering recursive. It only renders one image for each teleporter per frame, but the images accumulate nested/recursive sub-images across several frames. This uses a similar system to 3DWorld's reflective objects. Here is what the player sees when looking through a series of two teleporters, one in the lobby and the other on the roof.

Recursive view through two teleporter portals in the lobby and on the roof.

I decided that I wanted to have some fun with teleporters. I made a freeze gun a few months ago, but nothing is more fun and insane that turning a teleporter into a weapon! I have a new player secondary fire mode for the dodgeball that will instead fire a teleporter that bounces and floats around the scene, teleporting any dynamic objects within range. In particular, it can be used to teleport other players (and yourself if you're not careful). Where should it teleport them? Into outer space? That would be funny, but it takes too long to die. A better solution is to teleport them into the clouds so that they fall and splat on the scene below. It will be literally raining smileys (and body parts). I even added a screaming sound that plays while falling. However, I didn't add portal textures to these teleporters, because it's not too interesting to see inside sky and clouds.

Teleporters are very strange physics objects. They float with only a tiny amount of gravity. They're friction-less and slide across surfaces. They're non-solid so some objects can pass through them. Any gameplay objects (players, rockets, proximity mines, pickup items, body parts, blood, bouncy balls, etc.) can be teleported. Teleporters last for a limited amount of time (around 30s), and there can only be a few of them active at a time.

Here is a video of the teleporter gun in action. Note that the blue smileys are enemies and the red smileys are teammates, though I like to teleport my teammates to their deaths just for fun. You can see how the teleporter teleports a smiley hat, a burning skull, and some proximity mines as well. I teleport suicide twice in the video. Both times you can see objects that have lower terminal velocity than the player in the air as I'm falling. These objects were teleported into the sky a few seconds before I was. An enemy fired a seek-and-destroy (similar to a rocket) at me from the right side just before I teleported the first time. If you look carefully, you can see it exiting the teleporter at the same time as me and flying off into the sky.



Oh, and you can teleport a dynamic teleporter through a fixed/static teleporter. This happens to "just work" in my system.

You might try to be smart and block a teleporter with a movable object such as the chair. That will work if the chair is static; the teleporter will simply bounce off it. However, if the player is pushing the chair, both the player and the chair will be teleported into the sky. The player will hit the ground first. If you're lucky, your eyeball will be looking up after you die to see the chair land on top of it. I would post a video of this if it was easier to pull off.

Here is a screenshot showing multiple teleporters bouncing around. They're drawn using additive blending + emissive 3D animated volumetric procedural clouds. Each one is unique! They even emit dynamic light that changes color over time. You can see the lighting on the ceiling of the office building lobby in the image below.

Multiple dynamic bouncing teleporter objects. The goal is to not be hit by any of them.

That's it. This was a short post. I just wanted to get something out while I'm working on the procedural city update. Teleporters were challenging to integrate into the physics and gameplay system, but were extremely fun to play with.

No comments:

Post a Comment