Random teleporter

I am trying to build a teleporter that sends the player to a random spot on the level. Not to a predetermined location but completely and totally random. Can anyone suggest a good tutorial on doing exactly that? I have searched for one and have not found it yet.

Hi man,
If you are using Navmesh here a cool one https://www…com/watch?v=M2uCNqMa4FA
if you are not, you have to create your own sistem,
casting linetracing and getting impactpoints …

Thank you for your reply but that video is not really what I am looking for.

What Est_engine suggests is what you are asking for. It is completely random. Is also ensures your player will not spawn in a wall or in the void. Hook up random navigable point to teleport and make the radius as big as you need.

In the video that was provided, the AI runs to a sphere and then the sphere teleports to a random spot but the player does not.
I need one that teleports the player to a random spot when the player runs into it.

Get the bounds of your level. Get a Random point in Bounds, line trace down, take the hit location and spawn

get random location in navigable radius - move to

It is usually at this point that I am told to learn something. Still don’t know much about BP but I am making an effort.

Here you go. Hope you’re ready. :slight_smile:

You’ll need two Blue Print classes of type Actor.

**BP #1 will be used to define your level bounds (Teleporter Level Bounds). **
This class has a Box collision component scaled to fit the width and length of the level. The height should be around 50 units. No Collision, does not generate overlaps or hits. It is only used to get an extent, then a random point in said extent.

Place only one of these actors in your level. Center it and adjust the Z coordinate so the bottom of the box collision is slightly above the tallest point in the level.

BP #2 will be the Teleporter (RandomTeleporter).

This class will also have a collision component. Type/shape is up to you. I’m using box for this demo.
Collision settings should Overlap only the character…pawn or pawn capsule etc. Nothing else should be able to trigger the overlap.

On Component Begin Overlap (box) - creates a reference for the character and a reference for the teleporter level bounds. It then calls a custom event to choose a random location.

Get Random Location (event) - Validates both previously set vars (is valid). It then increments an attempt int, compares it against attempt limit (infinite loop control). From here you get the box collision bounds -> world location, scaled box extent -> Random Point in Bounding Box. The result is multiplied on Z vector and used in a line trace by channel.

We are doing a trace from the point above the level, down to the ground. The Z multiplier needs to be great enough that it hits.

From here you take the hit location and adjust for the characters capsule component. Pass this and the capsules world rotation to the Teleport Player (event).

Teleport Player (event) - Simply pass the values to Teleport node. Check results with a branch. If it fails call Get Random Location event, otherwise reset the attempts int to 0.

Be sure to set your Attempts Limit variable to something other than 0.

Here’s a demo vid that includes BP overview. Level size in demo is 4KM x 4KM. In the vid I’m using a custom teleport to get me back to the teleporter box…just fyi.

https://.com/watch?v=ZjyLKMkE3JM