# How to add an ActorComponent created in blueprints to an Actor created in c++?

**URL:** <https://forums.unrealengine.com/t/how-to-add-an-actorcomponent-created-in-blueprints-to-an-actor-created-in-c/325256>\
**Category:** Blueprint\
**Tags:** actorcomponent, fobjectfinder, unreal-engine, CPP, question\
**Created:** [July 14, 2015, 8:27pm UTC](https://forums.unrealengine.com/t/how-to-add-an-actorcomponent-created-in-blueprints-to-an-actor-created-in-c/325256 "2015-07-14T20:27:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ghar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ghar](https://forums.unrealengine.com/u/Ghar)\
**Post date:** [July 14, 2015, 8:27pm UTC](https://forums.unrealengine.com/t/how-to-add-an-actorcomponent-created-in-blueprints-to-an-actor-created-in-c/325256/1 "2015-07-14T20:27:01Z")

</div>

I have a custom ActorComponent created with blueprints. Now I am creating a new Character in code, but I haven’t been able to find an example on how to add the component to the Character.

This is what I have so far:

h:

```
UCLASS()
class ZOMBIECOUNT_API AZCParentCharacter : public ACharacter
{
	GENERATED_BODY()

public:
	// Sets default values for this character's properties
	AZCParentCharacter();

	UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = ActorComponents)
	UActorComponent* ACTargetableComponent;
};

```

cpp:

```
AZCParentCharacter::AZCParentCharacter()
{
 	// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	static ConstructorHelpers::FObjectFinder <UActorComponent>ACTargetableC(TEXT("Blueprint'/Game/Blueprints/Components/AC_Targetable.AC_Targetable'"));
	if (ACTargetableC.Object != NULL)
	{
		ACTargetableComponent = ACTargetableC.Object;
	AddInstanceComponent(ACTargetableComponent);
	}
}

```

But when I open the project I get:

![50198-notfounimag.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/a/c/2ac670d7b53e19f5ffe7d032898daf040506c7be.jpeg)

If I create a blueprint based on AZCParentCharacter, it doesn’t have the component in the components tab:

 ![50199-imgcomponents.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/3/1/3316b42ca006ae9b59c1b4a4ad9e70097b0b82ff.jpeg)

The path to the component must be right because I right clicked it in the Editor, then clicked “Copy Reference”, and pasted it in the function.

I have a feeling everything I’ve done is wrong lol. Any help is appreaciated.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_eb3276d7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_eb3276d7](https://forums.unrealengine.com/u/anonymous_user_eb3276d7)\
**Post date:** [July 15, 2015, 2:48pm UTC](https://forums.unrealengine.com/t/how-to-add-an-actorcomponent-created-in-blueprints-to-an-actor-created-in-c/325256/2 "2015-07-15T14:48:11Z")

</div>

I haven’t done this before but I have a few thoughts about what’s wrong here

ConstructorHelpers::FObjectFinder ACTargetableC(TEXT(“Blueprint’/Game/Blueprints/Components/AC\_Targetable.AC\_Targetable’”));

you need to load the blueprint first so change UActorComponent to UBlueprint, and get the components inside of it. You can get the detailed class structure in debugger, that’s how I would do it

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_eb3276d7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_eb3276d7](https://forums.unrealengine.com/u/anonymous_user_eb3276d7)\
**Post date:** [July 15, 2015, 2:50pm UTC](https://forums.unrealengine.com/t/how-to-add-an-actorcomponent-created-in-blueprints-to-an-actor-created-in-c/325256/3 "2015-07-15T14:50:30Z")

</div>

One thing I failed to mention is that you can create an object from bluerpint-\>GeneratedClass
