# AttachTo in constructor

**URL:** <https://forums.unrealengine.com/t/attachto-in-constructor/321846>\
**Category:** Character & Animation\
**Tags:** unreal-engine, bug-report, question\
**Created:** [June 15, 2015, 10:13am UTC](https://forums.unrealengine.com/t/attachto-in-constructor/321846 "2015-06-15T10:13:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_66a0fcb6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_66a0fcb6](https://forums.unrealengine.com/u/anonymous_user_66a0fcb6)\
**Post date:** [June 15, 2015, 10:13am UTC](https://forums.unrealengine.com/t/attachto-in-constructor/321846/1 "2015-06-15T10:13:11Z")

</div>

Hi,

I don’t know if this is a real bug or intended design, but using AttachTo inside the constructor may cause a lot of problems. In my case, I have a Billboard Component that I create and Attach to my root inside my class constructor. However this eventually causes a crash. The error I get says that the engine attempts to detach the Billboard Component from the Collision Cylinder but it’s not attached to anything.

I moved the Attach To to PostInitializeComponents. Currently I am getting the following warnings (but no crashes as of yet).

```
[2015.06.15-10.05.15:583][513]LogActor:Warning: Natively added component (Enemy_StaticBot_C_3.CollisionCylinder) was left unattached from the actor's root.
[2015.06.15-10.05.29:614][319]LogActor:Warning: Natively added component (Enemy_StaticBot_C_4.CollisionCylinder) was left unattached from the actor's root.
[2015.06.15-10.05.34:829][618]LogActorComponent: UnregisterComponent: (/Engine/Transient.CharMoveComp) Not registered. Aborting.
[2015.06.15-10.05.35:904][682]BlueprintLog: New page: Compile Enemy_StaticBot
[2015.06.15-10.05.35:953][682]LogActor:Warning: Natively added component (Enemy_StaticBot_C_0.CollisionCylinder) was left unattached from the actor's root.
[2015.06.15-10.05.35:956][682]LogActor:Warning: Natively added component (Enemy_StaticBot_C_1.CollisionCylinder) was left unattached from the actor's root.
[2015.06.15-10.05.35:958][682]LogUObjectGlobals:Warning: Guid is in use by CapsuleComponent /Game/Maps/World_0.World_0:PersistentLevel.Enemy_StaticBot_2.CollisionCylinder and CapsuleComponent /Game/Maps/World_0.World_0:PersistentLevel.Enemy_StaticBot_C_1.CollisionCylinder, which should never happen in the editor but could happen at runtime with duplicate level loading or PIE
[2015.06.15-10.05.35:958][682]LogUObjectGlobals:Warning: Guid is in use by ArrowComponent /Game/Maps/World_0.World_0:PersistentLevel.Enemy_StaticBot_2.Arrow and ArrowComponent /Game/Maps/World_0.World_0:PersistentLevel.Enemy_StaticBot_C_1.Arrow, which should never happen in the editor but could happen at runtime with duplicate level loading or PIE
[2015.06.15-10.05.35:958][682]LogUObjectGlobals:Warning: Guid is in use by CharacterMovementComponent /Game/Maps/World_0.World_0:PersistentLevel.Enemy_StaticBot_2.CharMoveComp and CharacterMovementComponent /Game/Maps/World_0.World_0:PersistentLevel.Enemy_StaticBot_C_1.CharMoveComp, which should never happen in the editor but could happen at runtime with duplicate level loading or PIE
[2015.06.15-10.05.35:958][682]LogUObjectGlobals:Warning: Guid is in use by SkeletalMeshComponent /Game/Maps/World_0.World_0:PersistentLevel.Enemy_StaticBot_2.CharacterMesh0 and SkeletalMeshComponent /Game/Maps/World_0.World_0:PersistentLevel.Enemy_StaticBot_C_1.CharacterMesh0, which should never happen in the editor but could happen at runtime with duplicate level loading or PIE
[2015.06.15-10.05.35:958][682]LogUObjectGlobals:Warning: Guid is in use by BillboardComponent /Game/Maps/World_0.World_0:PersistentLevel.Enemy_StaticBot_2.LockGraphic and BillboardComponent /Game/Maps/World_0.World_0:PersistentLevel.Enemy_StaticBot_C_1.LockGraphic, which should never happen in the editor but could happen at runtime with duplicate level loading or PIE

```

Notably the “Collision Cylinder was left unattached”.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [June 16, 2015, 9:56pm UTC](https://forums.unrealengine.com/t/attachto-in-constructor/321846/2 "2015-06-16T21:56:48Z")

</div>

Hi Swiftle,

Can you provide the code files for this project so that I can attempt to look through and debug them? Without seeing the code itself, I can’t get much context as to what may be the issue. If it is a private project that you don’t wish to share with the public, you can also send a link to me on the forums through a private message. My forum username is

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_66a0fcb6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_66a0fcb6](https://forums.unrealengine.com/u/anonymous_user_66a0fcb6)\
**Post date:** [June 17, 2015, 7:09am UTC](https://forums.unrealengine.com/t/attachto-in-constructor/321846/3 "2015-06-17T07:09:34Z")

</div>

Hi,

Here are 2 .txt files that contain the .cpp and .h of Game Mode and my bot.link text

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [June 18, 2015, 3:38pm UTC](https://forums.unrealengine.com/t/attachto-in-constructor/321846/4 "2015-06-18T15:38:34Z")

</div>

Hi Swiftle,

I was able to reproduce the crash and actually workaround it in a way I currently don’t understand. Try changing the UProperty specifiers for the declaration of this UBillboardComponent to EditAnywhere instead of EditDefaultsOnly. This immediately fixed the ensure I was getting along with the crash. As to why EditDefaultsOnly was causing this, I’m currently looking into that and I’ll get back to you as soon as possible.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [June 23, 2015, 2:16pm UTC](https://forums.unrealengine.com/t/attachto-in-constructor/321846/5 "2015-06-23T14:16:02Z")

</div>

We’re still unsure of why exactly this issue is occurring but a bug has been put into our database for the issue. For your reference, the bug number is UE-17400.

Have a nice day,

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_66a0fcb6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_66a0fcb6](https://forums.unrealengine.com/u/anonymous_user_66a0fcb6)\
**Post date:** [June 24, 2015, 1:32am UTC](https://forums.unrealengine.com/t/attachto-in-constructor/321846/6 "2015-06-24T01:32:34Z")

</div>

Hi ,

Thanks for your assistance.
