0

I have to create object like this:

UStaticMeshComponent* staticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("CustomStaticMesh"));

But I don't get how this works. Why do I add that angle bracket? I understand it has to do with templates but can't find the syntax for using template this way,

and is CreateDefaultSubobject a static function so I can call it without instantiating?

April
  • 71
  • 1
  • 2
  • 7

1 Answers1

0

CreateDefaultSubObject is only to be used inside of Constructors.

Use NewObject or in the case of an AActor derived class UWorld::SpawnActor to create these objects respectively outside of the constructor, typically at runtime.

The <> denotes the template type passed to the function.

DevilsD
  • 545
  • 1
  • 5
  • 12