How can I use GeometryScript blueprint functions in C++ code?

Hey, I guess you may already have solved your issue already, but you can find them by searching the engine code using your IDE - which is a super handy and generally applicable (I think?) way to find c++ equivalents in UE. So for instance, since there is a BP function called “Append Box” I searched for “AppendBox” which led me to MeshPrimitiveFunctions.cpp.

This particular function you can then call like this:

void ADiggableGeometry::OnConstruction(const FTransform& Transform)
{
	UDynamicMesh* DM = DynamicMeshComponent->GetDynamicMesh();
	DM->Reset();

	FTransform T;
	FGeometryScriptPrimitiveOptions Options;
	UGeometryScriptLibrary_MeshPrimitiveFunctions::AppendBox(DM, Options, T, 100, 200, 400);
	
	Super::OnConstruction(Transform);
}

Placing this in a ADynamicMeshActor subclass will create a simple rectangle when you drag it into the editor window. There are lots of functions available in c++, just type UGeometryScriptLibrary_ and you should see a huge list in your IDE :slight_smile:

1 Like