# Failed Import UBoxComponent

**URL:** <https://forums.unrealengine.com/t/failed-import-uboxcomponent/311660>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [March 19, 2015, 4:10am UTC](https://forums.unrealengine.com/t/failed-import-uboxcomponent/311660 "2015-03-19T04:10:41Z")\
**Posts on this page:** 10\
**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:** [March 19, 2015, 4:10am UTC](https://forums.unrealengine.com/t/failed-import-uboxcomponent/311660/1 "2015-03-19T04:10:41Z")

</div>

Hello,

I’m encountering the following bug. My bot character has a UBoxComponent that is only used for collision done by touch (for mobile devices). The component is created with the `ObjectInitializer.CreateDefaultSubobject()`.

When I place more that one bot actor in the level I get this error on launch. The funny part is that the bot that should be missing it, have their UBoxComponent initialized, visible in game and working during play. It’s like a false error report of some sorts.

I’m using the latest source version of the engine 4.7.3.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [March 19, 2015, 1:46pm UTC](https://forums.unrealengine.com/t/failed-import-uboxcomponent/311660/2 "2015-03-19T13:46:35Z")

</div>

Hey -

What is the error message you get? Additionally, ObjectInitializer is no longer necessary when creating a component. Instead the call can be made with `VariableName = CreateDefaultSubobject(TEXT("FriendlyName"));`

Cheers

---

<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:** [March 20, 2015, 1:09am UTC](https://forums.unrealengine.com/t/failed-import-uboxcomponent/311660/3 "2015-03-20T01:09:29Z")

</div>

Hello ,

The error message I get says `Failed Import for BoxComponent` and then it links one of my placed bots in the level. I find this weird because as I said, the component is actually present on the bot and is working properly. Moreover, the bots also have a UBillboardComponent that’s created in the exact same way and I never had any issue with it.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [March 20, 2015, 2:33pm UTC](https://forums.unrealengine.com/t/failed-import-uboxcomponent/311660/4 "2015-03-20T14:33:39Z")

</div>

Hey -

Getting a “Failed Import” error for something created in code seem confusing. How is the BoxComponent attached to the bot? Could you post the header and source file for the class where the boxcomponent is being created?

---

<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:** [March 23, 2015, 1:16am UTC](https://forums.unrealengine.com/t/failed-import-uboxcomponent/311660/5 "2015-03-23T01:16:26Z")

</div>

Hello , wasn’t available during the weekend so I just saw your reply.

Here’s the code for the box component. I’m also posting the code for a billboard component that works fine with no errors:

.h

```
protected:
	/** Touch Collision Box */
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Collision, meta = (AllowPrivateAccess = "true"))
	class UBoxComponent* TouchBox;

public:
	FORCEINLINE class UBoxComponent* GetTouchBox() const { return TouchBox; }
};

/** Sprite used for the target lock */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Targeting)
UBillboardComponent* LockDecal;

```

.cpp

```
AThirdPersonShooterBot::AThirdPersonShooterBot(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer){
	AIControllerClass = AThirdPersonShooterBotController::StaticClass();
	static ConstructorHelpers::FClassFinder<UTPSWidget_EnemyHealth> WidgetClass(TEXT("/Game/UI/EnemyHealth.EnemyHealth_C"));
	if (WidgetClass.Class != NULL)
	{
		HealthWidgetClass = WidgetClass.Class;
	}
	GetMesh()->bReceivesDecals = false;

	TouchBox = ObjectInitializer.CreateDefaultSubobject<UBoxComponent>(this, TEXT("TouchBox"));
	TouchBox->SetCollisionResponseToChannel(COLLISION_PROJECTILE, ECR_Overlap);
	TouchBox->SetCollisionResponseToChannel(COLLISION_WEAPON, ECR_Overlap);
	TouchBox->SetCollisionResponseToChannel(COLLISION_TOUCH, ECR_Block);
	TouchBox->AttachTo(RootComponent);
	TouchBox->SetRelativeScale3D(FVector(3.5, 1.0, 3.5));
	TouchBox->SetRelativeRotation(FRotator(0, 90, 0));
	// TEMP
	TouchBox->bHiddenInGame = false;

	LockDecal = ObjectInitializer.CreateDefaultSubobject<UBillboardComponent>(this, TEXT("LockGraphic"));
	LockDecal->AttachTo(RootComponent);
	LockDecal->bVisible = false;
	LockDecal->bHiddenInGame = false;

	// Parameter setting
	MaxHealth = 25;
	CurrentHealth = MaxHealth;
}

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [March 23, 2015, 8:13pm UTC](https://forums.unrealengine.com/t/failed-import-uboxcomponent/311660/6 "2015-03-23T20:13:45Z")

</div>

Hey -

There is a bit of code that seems specific to your project. Are you able to reproduce the bug in a new project with no additional content? If so what are the steps used to setup the boxComponent? Also, do you get the same error if you change the TouchBox from “protected” to “public”?

---

<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:** [March 24, 2015, 1:39am UTC](https://forums.unrealengine.com/t/failed-import-uboxcomponent/311660/7 "2015-03-24T01:39:37Z")

</div>

Hello , I wasn’t able to replicate this on an entirely new project but something interesting happened when I tried it on a previously existing one.

I thought that the said project was vanilla but it seems like I have added my own Character Movement Component to the Player Character. Here’s what happened

1. Added a new C++ class based on Character and named it Bot
2. Closed the editor and opened Visual Studio.
3. Copy pasted the code for the Touch Component but this time I removed the `AllowPrivateAcess` and created the object without using the ObjectInitializer as you suggested above.
4. Compiled and reopened the editor.
5. Created a new blueprint based on Bot.h and set 3 of those guys in my scene.
6. Closed the editor and opened it up again.
7. On open I got a similar error stating that it Failed Import for my Character Movement Component on the Player’s Character present in the level.

This error only occurred after I set up those bots. I know it’s not a new project but it’s weird to get such an error after adding this component to a completely unrelated character.

P.S Also changing the component from protected to public doesn’t help as I’m still getting the same error.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [March 24, 2015, 3:54pm UTC](https://forums.unrealengine.com/t/failed-import-uboxcomponent/311660/8 "2015-03-24T15:54:03Z")

</div>

Hey -

I tried following the steps in a first person and third person template with no error. If you are unable to reproduce the bug in a new project then the code for your bot may be interfering with code elsewhere. Would it be possible to send us a copy of the project where the bug is occurring? If you’re able to upload the project to dropbox you can send me a private message on the forums with a link. At minimum would it be possible to send the source and header files for the bot class you’re creating?

Cheers

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [April 3, 2015, 3:05pm UTC](https://forums.unrealengine.com/t/failed-import-uboxcomponent/311660/9 "2015-04-03T15:05:27Z")

</div>

Hey -

Sorry for the delay however I have the chance to test the project you sent me on the forums. I’m still not sure what is causing the error when opening the project (since the component seems to be working in game) but I did find that by changing it from a UBoxComponent to a USphereComponent the error went away and did not return when I set it back to a UBoxComponent. Try changing the component type in the code and let me know if you still get the same error when you save and reopen the project.

Cheers

---

<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:** [April 6, 2015, 1:29am UTC](https://forums.unrealengine.com/t/failed-import-uboxcomponent/311660/10 "2015-04-06T01:29:34Z")

</div>

Hello ,

Sometime in between code modifications the issue disappeared.
