I’m currently spawning a large number of decals for stuff like bullet impact effects through both code and blueprint, going through the UGameplayStatics decal spawning functions. I have noticed that it appears that decals are being garbage collected at regular intervals, meaning they all disappear very suddenly - upon looking for an equivalent for the UE3 decal manager, it appears that there isn’t one?
Are there any plans to include a basic decal manager any time soon, and if not, are there any caveats or things I should bear in mind when implementing one?
I encountered this issue in the Beta (it was puzzling me quite intensely), while making footprint system for Solus
The simplest level of the solution is this:
UPROPERTY()
TArray<UDecalComponent*> Decals;
That’s the essential core, you can add any manner of additional functionality, but as long as decals get put in a UPROPERTY() anything, they will survive forever
I ultimately wrapped my array in a USTRUCT for easy data manipulation without making an entire class.
if you do that make sure to make the USTRUCT UPROPERTY() where it is created in your gameplay class, and also make the Tarray UPROPERTY() inside of the USTRUCT itself
(same goes for making a class)
That’s it!
Just put UPROPERTY() everywhere and your decals will last indefinitely
This is pretty much what the UE3 DecalManager does, and a couple of other things aside. I’m wondering if I should be doing anything like memory management at any point though, as over the course of a long game, I can imagine that you may end up with a lot of decals…
I ran some preliminary tests and there is indeed a limit to how many decals UE4 likes to display in a single screen space, but I dont have exact numbers and it will vary machine to machine.
So I dont have any thing conclusive for you, but I did this as a result:
#Decal Density Management
If I have many footprints within a small area of about 1.5 or 2 x decal size, I quietly fade out all the extra to reduce that density.
User will get the idea of what is going on, the overall shape of the effect, by just seeing 1 (or a few)
might be useful for the kind of decals you are talking about