Create cylinder mesh programmatically?

I’m trying to create a series of cylinders programmatically when an actor begins play. I’m trying to do this using this method:

UCylinderBuilder builder = UCylinderBuilder();
builder.BuildCylinder(0, false, 6, 100, 10);

But I get the compiler error: UCylinderBuilder() is a private constructor.

What’s the right way to create a cylinder mesh instance at runtime?

I think you need to look at A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums

1 Like

Here is some pseudo-c++ to get you started

StaticMeshComponent = ConstructObject<UStaticMeshComponent>(**COMPONENT CLASS GOES_HERE** (in your case, a cylinder mesh that you are going to import from a modelling program), GetOwner(), NAME_None, RF_Transient);
 // Add to map of components.
 StaticMeshComponents.Add(StaticMesh, StaticMeshComponent);
 StaticMeshComponent->AttachTo(this, NAME_None, EAttachLocation::KeepRelativeOffset);

You basically use the constructor object initializer to fabricate a new StaticMeshComponent with desired name, owner , based on a static mesh class (you need to import a cylinder fbx file - BSP brushes are a different thingm they get generated from code), then register the component and make it visible.

This is a more advanced way, in which you need to add a crazy amount of calculations just for the vertices. It should be used in stuff like terrain generation and wave simulation