How to dynamically create and destroy text component in UMG

I’m trying to implement floating damage numbers, and wondering if it is possible to dynamically create and destroy a text component within an existing instance of UMG at runtime. Specifically:

  • The text component that shows the damage number shall be transient. After it is displayed on the screen for a short period, it shall be removed, not just from the viewport, but from the memory, or forcibly garbage collected.

Thanks for any pointer!

In my setup I’m using a progress bar for showing a health value but the process is the same. Just create your text, set it to whatever number you want which is fed to it via your enemy character BP and then when you want the text to disappear either set it’s value to nothing or simply set the visibility to hidden.

I can’t imagine the benefit of creating and destroying the text constantly if it’s something that you’re going to use again on a regular basis but if you really want to learn how to create dynamic UMG elements, Creating a Dynamic UMG System | Community Led Training | Unreal Engine - YouTube

As I said though, it makes more sense to me to simply set the value of the text, play an animation to have it move a bit and fade out and then re-use it again immediately.

Thanks for your input. These two youtube videos can help solve the problems with BP scripting. For C++ developers, this article turns out extremely helpful: http://benhumphreys.ca/unreal/ui-bindwidget/

Glad I could help :slight_smile: