hi
currently i’m trying to make a grid generate system and it is my first project on unreal.
generator class has 3 variables which for number X, Y and size of grid block.
and based on these values create and visualize grid via Instanced Static Mesh Component.
but i have some trouble on creating component
i followed this post and result is like this
ABasicGrid::ABasicGrid()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
//m_pComponent_StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMesh"));
m_pComponent_InstancedStaticMesh = NewObject<UInstancedStaticMeshComponent>(this);
m_pComponent_InstancedStaticMesh->RegisterComponent();
m_pComponent_InstancedStaticMesh->SetFlags(RF_Transactional);
this->AddInstanceComponent(m_pComponent_InstancedStaticMesh);
}
that static mesh thing was for setting mesh for instanced static mesh component but after i have got some errors i deleted it temporarily.
i found some docs that tells me CreateDefaultSubobject is only for create Subobject(Component) and can use only in constructor, and NewObject is for create independent object so if i want to use it as component i should register it as component manually.
since it sounds like NewObject is much more generally usable, i thought NewObject is better than CreateDefaultSubobject.
but when i compile it, it returns error that says “NewObject with empty name can’t be used to create default subobjects ~~~”
and i can’t find any way to set name for newly created object.
how i set name object?