# What is the correct way to create and add components at runtime ?

**URL:** <https://forums.unrealengine.com/t/what-is-the-correct-way-to-create-and-add-components-at-runtime/15605>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [November 20, 2014, 5:40pm UTC](https://forums.unrealengine.com/t/what-is-the-correct-way-to-create-and-add-components-at-runtime/15605 "2014-11-20T17:40:42Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [November 25, 2014, 10:34pm UTC](https://forums.unrealengine.com/t/what-is-the-correct-way-to-create-and-add-components-at-runtime/15605/7 "2014-11-25T22:34:47Z")

</div>

I have fully tested just this workflow as working

PrimitiveComponent was my chosen base class, you could use Scene component for components that dont have collision.

```auto

 UPrimitiveComponent* NewComp = ConstructObject<UPrimitiveComponent>( CompClass, TheOwner, YourObjectName);
if(NewComp)
{
  NewComp->RegisterComponent();
  //attach or set location, etc
}

```

---

_[View the full topic](https://forums.unrealengine.com/t/what-is-the-correct-way-to-create-and-add-components-at-runtime/15605)._
