Unreal, like most game engines, has a failsafe for if the player falls out of the map and hits the KillZ. In Unreal this is called Fell Out Of World.
Internally the engine keeps track of your current height in the world, if you drop below that, the KillZ, the developer will teleport the player back into the world, usually to the last position you were in the world, but here we will be teleporting to a preset location.

How do we do this?

Before we get started, here’s what we want to change:

Falling from the world
Aaaaand he’s gone.

To start with you’ll need a C++ project, this currently cannot be overridden in blueprints.
Once you’ve got your C++ project you’ll need to create a new class based on ACharacter and call it whatever you want. Mine is BaseCharacter.

Add A Class selector
Selecting the Character class to derive from.

Adding the code to ABaseCharacter

Once you’ve got your custom ACharacter you’ll want to override FellOutOfWorld as seen in the image below.

Unreal ACharacter with FellOutOfWorld
ACharacter with FellOutOfWorld

Once you’ve got this you can go ahead and add this extra code to the .cpp file

ACharacter with FellOutOfWorld - CPP File
ACharacter with FellOutOfWorld – CPP file

This will now teleport the player back to the center of the world, plus 100 units up to account for the player capsuel size.

Falling out of the world then teleporting back to 0,0,0
Falling out of the world then teleporting back to 0,0,100

Final notes

FellOutOfWorld exists in every actor as it is implemented in AActor. This means you can do this to anything that falls below the KillZ. The KillZ can be changed by going to the World Settings then changing the KillZ variable under World. By default, this is set very high, well…low, but it would take a while for your player to hit it, so adjust accordingly.

The KillZ Variable
The KillZ Variable in World Settings

1 Comment

Get the current App Version with Expo and React Native · 7 July 2021 at 9:30 am

[…] and React Native. You can see some of my stuff with Unreal Engine on this site with posts such as Controlling What Happens on Fell Out Of World and Taking In-Game Screenshots with UI in Unreal […]

Comments are closed.