Unreal Engine Part 7: Teleporters

Portals and teleportation is a great pacing tool for making games

Portals and teleportation is a great pacing tool for making games

In chapter 7 of Rob Redman's comprehensive video introduction to Unreal Engine, he takes a closer look at teleporters to move your character quickly
from point to point...

We've got to the point where you should be comfortable setting up a landscape in Unreal, adding some environmental and camera effects, as well as toying with the possibilities of particle systems, but it's time to start adding some actions to the scene and a good one to get your teeth into is a teleporter, which allows your player to be instantly moved to another location.

For my example I added a second landscape, disconnected from the first and contained within a large room made of cubes. I added a large rock to the room, lit by a single spotlight, so the player will have no point of reference once they enter, building suspense.

There is no reason why you should do this (you could build anything you like, or simply move the player to another part of the same landscape) but it might be worth it to follow. Once ready let's get started.

Previous tutorials

Part 1: Setting up a new project
Part 2: Introducing materials and landscapes
Part 3: Adding foliage and rocks
Part 4: Particle smoke
Part 5: Introducing the skybox
Part 6: Setting up cameras and post-effects

Portals

The first thing we need to do is to define where and what our portals are. For the outward portal I'm going to use the statue but rather than adapting the mesh I'm going to add a simple boxtrigger, sized and placed to overlap the bounds of the statue, so that the player can enter the volume, causing the teleporter to activate. A second portal point (also a boxtrigger with the same settings) is added in my new room, under the spot light.

In the details tab of both portals set the collision preset to OverlapAllDynamics, so you don't get any unwanted interactions.

A simple way for our player to set the portal off.

A simple way for our player to set the portal off.

Level blueprint

From the blueprints menu above the viewer select edit level blueprint. With the trigger 2 selected right-click and choose add reference, so that we can access the trigger within the graph. We will need its location information, so drag off the output of the node and add 'Get actor location'. Now, right-click in the editor view (graph) and add a teleport node. Connect the getactorlocation's return value to the Destination Location input, which sets up the position the player will teleport to.

The built in teleport node is very handy.

The built in teleport node is very handy.

Who to teleport

It's possible to teleport pretty much anything you can push into the trigger's volume, which can be handy for certain games but for this we want to drive the narrative on, so it's our player we need to set as the teleport's target, so right-click and add a getplayerpawn node. You don't need any locations or anything here. Just the pawn is enough so connect the nodes.

The player pawn node allows access to any player. Just adjust the index to suit,
which could be used to control which player can teleport.

Active

If you try to play the level now nothing will happen and that's because you need an event state for the setup, so right-click in the editor and get an 'onactorbeginoverlap' and hook it up to the teleport.

This simple setup tells UE4 that when the player touches the trigger box (first one, by the statue) they need to be moved to the location of the second portal, as got from the getactorlocation.

Now press compile and head back to your level viewer.

A very simple setup for a really useful technique.

A very simple setup for a really useful technique.

Testing

Once you hit compile you should save your level and then press play. Make sure your character teleports as expected. If it doesn't work make sure you got your reference for the target and the overlap nodes the right way round.

You may also find you want to adjust the size and position of the two triggers, to aid in smoothness of gameplay. Once done you should be set to go and can then refine anything else like lighting or other props.

All set and ready to go to the next level.

All set and ready to go to the next level.

The teleporter is done and players can now go from the open-skied area to the closed-off cave. Next time we will take things a stage further and look at some more events, including dynamic objects that your player can interact with.

Top tip: Orientation

Use the orientation of the teleporter the player arrives at to either befuddle them or help them feel at ease by facing them toward or away from familiar landmarks.

Previous tutorials

Part 1: Setting up a new project
Part 2: Introducing materials and landscapes
Part 3: Adding foliage and rocks
Part 4: Particle smoke
Part 5: Introducing the skybox
Part 6: Setting up cameras and post-effects

Grab a copy of our Unreal Game Engine tutorial book today!

Fetching comments...

Post a comment