Controlling what happens on Fell Out Of World in UE4
May 17, 2021
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...aaand 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
Once you've got this you can go ahead and add this extra code to the .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
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 in World Settings
If this post helped you, please consider checking out a couple of my other posts also featuring Unreal Engine.
Or, you could consider helping me by supporting me on Ko-Fi at https://ko-fi.com/rhyce