Decay: Destroy Actors the Proper Way

A subsystem for Unreal Engine 5 for handling the destruction of Actors and Components

Category:
Tags: , , , , ,

Description

It is more than typical for new developers to destroy inactive Actors, such as corpses or hit impacts, after a certain amount of time. While this may work well in the short term for some games, it can cause serious performance issues when you start having dozens or even hundreds of these ‘dead’ Actors present.

Decay allows you to register an inactive Actor (or Component) to a Decay Instance (group) and Decay will decide when to destroy this Actor based on the game’s current state. This ensures your game keeps running smoothly.

Let’s say you have a Decay Instance (group) for Corpses with the following settings { lifetime: 30s, max objects: 15 }:

How-to-use

A Decay Instance is a group of decayable objects in your game. We recommend making a Decay Instance for every type of decayable object in your game, for example, one for Corpses, another for Bullet Impacts and another for Foliage. This allows Corpses and Bullet Impacts to act independently from each other. Alternatively, you could assign a Decay Instance in a priority fashion instead, such as VeryHigh, High, Normal and Low.

Decay Instances can be easily created by going to Project Settings > Plugins > Decay and then adding a CustomDecayInstance. The Tag you provide for the Decay Instance is what you will use to reference this Decay Instance later. Tags can be created just like another other Gameplay Tag.

The Default Decay Instance is the Decay Instance where objects will be automatically assigned to if no Decay Instance Tag is given and can be used as an ‘other’ decay group.

Instead of destroying an Actor or ActorComponent when it enters an inactive state (immediately or after time has passed), as you typically would, register the object with a Decay Instance by either:

Blueprint

That’s all you need to know to use Decay. For anything else, such as disabling Decay Instances or manually destroying objects, feel free to read the documentation within the code.

Technical Details

Code Modules:

Number of Blueprints: 0

Number of C++ Classes: 5

Network Replicated: No

Supported Development Platforms: Windows, macOS, Linux

Supported Target Build Platforms: Windows, macOS, Linux

Supported Engine Versions

5.2