# NewObject or CreateDefaultSubobject

**URL:** <https://forums.unrealengine.com/t/newobject-or-createdefaultsubobject/335095>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [October 12, 2015, 8:12pm UTC](https://forums.unrealengine.com/t/newobject-or-createdefaultsubobject/335095 "2015-10-12T20:12:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_e98844721](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e98844721](https://forums.unrealengine.com/u/anonymous_user_e98844721)\
**Post date:** [October 12, 2015, 8:12pm UTC](https://forums.unrealengine.com/t/newobject-or-createdefaultsubobject/335095/1 "2015-10-12T20:12:20Z")

</div>

Hi all,

I’d like to know what is the difference between the 2 methods stated in the title.

Example:

```
USphereComponent* Component = NewObject<USphereComponent>(this);

or

USphereComponent* SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent"));

```

Thank you.

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [October 12, 2015, 8:29pm UTC](https://forums.unrealengine.com/t/newobject-or-createdefaultsubobject/335095/2 "2015-10-12T20:29:18Z")

</div>

CreateDefaultSubobject in constructor (you need to decler component in constructor in order to see them in extended blueprint, other wise you creating component dynamicly), NewObject everywhere else

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e98844721](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e98844721](https://forums.unrealengine.com/u/anonymous_user_e98844721)\
**Post date:** [October 14, 2015, 1:16am UTC](https://forums.unrealengine.com/t/newobject-or-createdefaultsubobject/335095/3 "2015-10-14T01:16:50Z")

</div>

That simple!

Thank you.

---

<div class="post-metadata">

**Author:** ![Katianie](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Katianie](https://forums.unrealengine.com/u/Katianie)\
**Post date:** [November 11, 2015, 3:25am UTC](https://forums.unrealengine.com/t/newobject-or-createdefaultsubobject/335095/4 "2015-11-11T03:25:26Z")

</div>

+1 you read my mind.

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [November 11, 2015, 5:06am UTC](https://forums.unrealengine.com/t/newobject-or-createdefaultsubobject/335095/5 "2015-11-11T05:06:52Z")

</div>

I use the fact Katianie posted comment to extend the anwser. I never investigate that but my guess is CreateDefaultSubobject is designed to spawn component, because content of constructor is exclusivly used in Class Default Object (CDO) which could not have secundery objects spawned, CreateDefaultSubobject don’t spawn object but leaves information to create component object on spawn.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_24cff47d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_24cff47d](https://forums.unrealengine.com/u/anonymous_user_24cff47d)\
**Post date:** [September 25, 2017, 4:06am UTC](https://forums.unrealengine.com/t/newobject-or-createdefaultsubobject/335095/6 "2017-09-25T04:06:22Z")

</div>

From what I understand, NewObject creates and instance that is not visible to editor however instance created by CreateDefaultSubobject is visible to editor. For example, if you create instance of camera using CreateDefaultSubobject and attach it to your pawn, then that camera will actually appear as child of pawn in editor. This is also why CreateDefaultSubobject usage is restricted to constructor.

---

<div class="post-metadata">

**Author:** ![darkgaze](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@darkgaze](https://forums.unrealengine.com/u/darkgaze)\
**Post date:** [March 8, 2018, 7:57pm UTC](https://forums.unrealengine.com/t/newobject-or-createdefaultsubobject/335095/7 "2018-03-08T19:57:10Z")

</div>

But it is not editable and also you can’t modify some stuff on them. They appear as Inherited components… a little hidden there. Sometimes they don’t come up unless it’s the rootComponent… (4.18)

---

<div class="post-metadata">

**Author:** ![reza.darooei](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@reza.darooei](https://forums.unrealengine.com/u/reza.darooei)\
**Post date:** [November 19, 2018, 8:31am UTC](https://forums.unrealengine.com/t/newobject-or-createdefaultsubobject/335095/8 "2018-11-19T08:31:39Z")

</div>

if we want create something dynamically or in other word creating in Run-time we are using newobject but createdefaultsubject it is not for creating something dynamically we create it once.
