How to Create UTextureRenderTarget2D c++

I\m trying to create a Texture to give to a SceneCaptureComponent2D.

class USceneCaptureComponent2D *sceneCaptureActor = (class USceneCaptureComponent2D *)GetWorld()->SpawnActor<USceneCaptureComponent2D>(USceneCaptureComponent2D::StaticClass());
class UTextureRenderTarget2D *renderTarget2D = (class UTextureRenderTarget2D *)NewObject<class UTextureRenderTarget2D>(sceneCaptureActor);
sceneCaptureActor->TextureTarget = renderTarget2D;

I get the following error which i do not know how to fix

-use of undefined type ‘UTextureRenderTarget2D’

-see declaration of ‘UTextureRenderTarget2D’

-see reference to function template instantiation ‘T *NewObject(UObject *)’ being compiled

Thanks for the help

It looks like you’ve forgot to include TextureRenderereTarget2D.h in your header/cpp file.

As a side note: you don’t need to put forward declaration every time you use that type.

Cheers.

1 Like

For anyone that can’t find it, the actual include is:
#include "Engine/TextureRenderTarget2D.h"