# How do I Register ActorComponents in UE5 blueprints?

**URL:** <https://forums.unrealengine.com/t/how-do-i-register-actorcomponents-in-ue5-blueprints/504907>\
**Category:** Editor Scripting\
**Tags:** unreal-engine, UE5-0, editor, question, Blueprint, UE4-27\
**Created:** [March 8, 2022, 4:22am UTC](https://forums.unrealengine.com/t/how-do-i-register-actorcomponents-in-ue5-blueprints/504907 "2022-03-08T04:22:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JPMcWhiskers](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JPMcWhiskers](https://forums.unrealengine.com/u/JPMcWhiskers)\
**Post date:** [March 8, 2022, 4:22am UTC](https://forums.unrealengine.com/t/how-do-i-register-actorcomponents-in-ue5-blueprints/504907/1 "2022-03-08T04:22:41Z")

</div>

Hi! Long time reader, first time poster.

Quick question for you all with a bit of background: I am currently using Unreal Engine 5 preview 1.  
Trying to create some simple procedurally created buildings by gluing a bunch of premade assets together. I am doing this through blueprint by Adding an InstancedStaticMeshComponent to the building actor and adding the various walls and floors that I need. Working great, really fast, everything is good. Except…

Whenever I move the building actor, the mesh disappears. From my googling I think I’ve understood that the Component itself hasn’t been saved after it’s been filled with data, so there’s some under the hood redraw process that’s boning me.

So here’s my two related (hopefully) questions:  
1.How do I Register the new component that I’ve made through my blueprint so it shows up in the Actor’s hierarchy?  
2. How do I save ActorComponent changes that were made via blueprint so when I move the actor the changes don’t disappear or reset?

Thanks for your time, if you need any more info, let me know.

---

<div class="post-metadata">

**Author:** ![chpsemail](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chpsemail/32/496464_2.png) [@chpsemail](https://forums.unrealengine.com/u/chpsemail)\
**Post date:** [March 9, 2022, 9:49am UTC](https://forums.unrealengine.com/t/how-do-i-register-actorcomponents-in-ue5-blueprints/504907/2 "2022-03-09T09:49:07Z")

</div>

I think add component in the actor’s construct function will works. Just like the room of content example.  
If you want add the component dynamic, my way is add a blueprintcallable func in Blueprint library.  
For example:

```auto
UActorComponent* UPythonBPLib::AddComponent(TSubclassOf<class UActorComponent> ComponentClass, AActor* Actor, USceneComponent* ParentComponent, FName Name)
{
	
	UActorComponent* Result = nullptr;
	if (!ComponentClass.Get())
	{
		UE_LOG(PythonTA, Error, TEXT("AddComponent. ComponentClass is not valid."));
		return nullptr;
	}

	Result = NewObject<UActorComponent>(Actor, ComponentClass.Get(), Name);
	USceneComponent* AsSceneComponent = Cast<USceneComponent>(Result);
	if (AsSceneComponent) 
	{
		AsSceneComponent->AttachToComponent(ParentComponent ? ParentComponent : Actor->GetRootComponent(), FAttachmentTransformRules::KeepRelativeTransform);
		FTransform T;
		AsSceneComponent->SetComponentToWorld(T);
	}
	Actor->AddInstanceComponent(Result);
	Result->OnComponentCreated();
	Result->RegisterComponent();

	Actor->RerunConstructionScripts();
	
	return Result;
}

```

Then call it in bp or python. I call it in my python tool like this:

```auto
meshComp = unreal.PythonBPLib.add_component(unreal.HierarchicalInstancedStaticMeshComponent, actor, actor.root_component)

```

Then the component will be in the actor’s hierarchy.

Below is my blueprint library documentation.

> **[PythonBPLib](https://www.tacolor.xyz/pages/PythonEditorLib/PythonBPLib.html#add_component)**
>
> Python Interface of Extended Editor: PythonBPLib | UE Plugin TAPython documentation

---

<div class="post-metadata">

**Author:** ![JPMcWhiskers](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JPMcWhiskers](https://forums.unrealengine.com/u/JPMcWhiskers)\
**Post date:** [March 10, 2022, 3:35pm UTC](https://forums.unrealengine.com/t/how-do-i-register-actorcomponents-in-ue5-blueprints/504907/3 "2022-03-10T15:35:15Z")

</div>

Thanks for the above!

For anyone else wondering if there’s a way to do this in Blueprints only, here’s what I’ve learned:  
ActorComponents can be added to Actors but will not show up in the Inspector, nor will data added to them be persisted if the actor is moved.

Variables, on the other hand are persisted. Can components be variables? Yes, but through a proxy.

What I did to make this work was to simply create an Actor “InstancedStaticMeshComponentProxy” and to that actor add the InstancedStaticMesh component.

Then, in my original Actor Component, create an Array of InstancedStaticMeshComponentProxy objects. Whenever I want to dynamically add one, I simply “Create New Instance” in the script and assign whatever mesh and material I want to it.

You can use this method to create mutliple persistent instances of InstanceStaticMeshComponent on the fly, only using blueprints.

---

<div class="post-metadata">

**Author:** ![hardviper](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hardviper](https://forums.unrealengine.com/u/hardviper)\
**Post date:** [August 30, 2023, 2:38am UTC](https://forums.unrealengine.com/t/how-do-i-register-actorcomponents-in-ue5-blueprints/504907/4 "2023-08-30T02:38:12Z")

</div>

Hello!  
Could you send a code example?
