# How to create a cylinder in c++

**URL:** <https://forums.unrealengine.com/t/how-to-create-a-cylinder-in-c/467194>\
**Category:** C++\
**Tags:** actorcomponent, unreal-engine, question, CPP\
**Created:** [June 24, 2020, 4:49pm UTC](https://forums.unrealengine.com/t/how-to-create-a-cylinder-in-c/467194 "2020-06-24T16:49:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![antonio\_gamedev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@antonio\_gamedev](https://forums.unrealengine.com/u/antonio_gamedev)\
**Post date:** [June 24, 2020, 4:49pm UTC](https://forums.unrealengine.com/t/how-to-create-a-cylinder-in-c/467194/1 "2020-06-24T16:49:32Z")

</div>

Hello, I would like to create a cylinder in c++, I can create boxes component and spheres, are there any cyilinder?

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [June 24, 2020, 5:15pm UTC](https://forums.unrealengine.com/t/how-to-create-a-cylinder-in-c/467194/2 "2020-06-24T17:15:10Z")

</div>

Are you talking about static meshes or collision shapes? If the latter then no. There are only spheres, boxes and capsules collision shapes.

---

<div class="post-metadata">

**Author:** ![antonio\_gamedev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@antonio\_gamedev](https://forums.unrealengine.com/u/antonio_gamedev)\
**Post date:** [June 24, 2020, 5:18pm UTC](https://forums.unrealengine.com/t/how-to-create-a-cylinder-in-c/467194/3 "2020-06-24T17:18:04Z")

</div>

static mesh

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [June 24, 2020, 5:27pm UTC](https://forums.unrealengine.com/t/how-to-create-a-cylinder-in-c/467194/4 "2020-06-24T17:27:01Z")

</div>

How are you creating them?

---

<div class="post-metadata">

**Author:** ![antonio\_gamedev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@antonio\_gamedev](https://forums.unrealengine.com/u/antonio_gamedev)\
**Post date:** [June 24, 2020, 5:41pm UTC](https://forums.unrealengine.com/t/how-to-create-a-cylinder-in-c/467194/5 "2020-06-24T17:41:24Z")

</div>

I have understood, I do it in the blueprint editor.

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [June 24, 2020, 5:52pm UTC](https://forums.unrealengine.com/t/how-to-create-a-cylinder-in-c/467194/6 "2020-06-24T17:52:32Z")

</div>

To add a cylinder static mesh:

```
  #include "Components/StaticMeshComponent.h"
  #include "Engine/StaticMesh.h"

   ...

    UStaticMeshComponent* Cylinder= CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualRepresentation"));
    Cylinder->SetupAttachment(RootComponent);
    static ConstructorHelpers::FObjectFinder<UStaticMesh> CylinderAsset(TEXT("/Game/StarterContent/Shapes/Shape_Cylinder.Shape_Cylinder"));
    if (CylinderAsset.Succeeded())
    {
        Cylinder->SetStaticMesh(CylinderAsset.Object);
        Cylinder->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
        Cylinder->SetWorldScale3D(FVector(1.0f));
    }

```

Just make sure, you have the starter content directory. Otherwise change the path to your cylinder mesh.
