Home

Projects

Posts

About

Contact

Hey! Just a note, this has been pulled from my old site so, while this site is being built, some things may not work correctly.


Controlling what happens on Fell Out Of World in UE4

17/05/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
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








If this post helped you, please consider checking out a couple of my other posts also featuring Unreal Engine.
Taking In-Game Screenshots with Unreal Engine
or
How To Make Custom Unreal Engine Nodes Easily.





Or, you could consider helping me by supporting me on Ko-Fi at https://ko-fi.com/rhyce