C++ Convert UTextureRenderTarget2D to UTexture2D

Hi there I have a code where I want to convert Texture 2D Render Target to Texture 2D. The code Builds fine however the node I get needs a target connected because is a non-static function.
I do I create a target for my BP Library? Or how can I remove ‘this’ if I make the function static?

.h

UFUNCTION(BlueprintCallable, Category = "Texture")
UTexture2D* GetTextureRenderTarget(UTextureRenderTarget2D* RTarget);

.cpp

UTexture2D* UTestBPLibrary::GetTextureRenderTarget(UTextureRenderTarget2D* RTarget)
{
	
	UTexture2D* Texture2D;

	Texture2D = RTarget->ConstructTexture2D(this, "texture", EObjectFlags::RF_NoFlags, CTF_DeferCompression);
	RTarget->CompressionSettings = TextureCompressionSettings::TC_VectorDisplacementmap;
#if WITH_EDITORONLY_DATA
	Texture2D->MipGenSettings = TextureMipGenSettings::TMGS_NoMipmaps;
#endif
	Texture2D->SRGB = 1;
	Texture2D->UpdateResource();

	return Texture2D;
}

You can remove the this argument from the ConstructTexture2D function by making the GetTextureRenderTarget function static.

Here’s how you can do that:

.h

UFUNCTION(BlueprintCallable, Category = "Texture")
static UTexture2D* GetTextureRenderTarget(UTextureRenderTarget2D* RTarget);

.cpp

UTexture2D* UTestBPLibrary::GetTextureRenderTarget(UTextureRenderTarget2D* RTarget)
{
    UTexture2D* Texture2D;

    Texture2D = RTarget->ConstructTexture2D("texture", EObjectFlags::RF_NoFlags, CTF_DeferCompression);
    RTarget->CompressionSettings = TextureCompressionSettings::TC_VectorDisplacementmap;
#if WITH_EDITORONLY_DATA
    Texture2D->MipGenSettings = TextureMipGenSettings::TMGS_NoMipmaps;
#endif
    Texture2D->SRGB = 1;
    Texture2D->UpdateResource();

    return Texture2D;
}

The this argument is only needed for non-static member functions, and it refers to the instance of the object that the function is being called on. Since you don’t need to access any object-specific data in your GetTextureRenderTarget function, you can make it static, which allows you to call it without an instance of the object.