Download

How to manage/delete runtime created TextureRenderTarget2D???

Hey everyone,

While i was busy creating a snowshader with deform-able snow I thought I was being clever by creating a TextureRenderTarget2D for every model i collided with, store it into an array, only to delete them again after a certain distance.
This is where i ran into a problem: Although there is a node to create a render target 2d dynamically, there is no node to remove them, once they are created. Am I missing something? Is there a workaround to delete them, or is this intended?

Thanks in advance for the help!

Jori “HarmlessNL” Kamp
Game designer at Turtleneck Studios

it must be deleted by garbage collector if nothing referencing it.
in case you store it in some variable, set it to None. Also replace it with some default texture in dynamic material instance.

Thank you very much for your quick reply! Because i coudn’t figure out how to delete it, I just went and cycle the textures, reusing them :slight_smile: works perfectly and should even be better then deleting/creating them over and over again!

Cheers!