# Access blueprint components from c++

**URL:** <https://forums.unrealengine.com/t/access-blueprint-components-from-c/309523>\
**Category:** Blueprint\
**Tags:** unreal-engine, editor, Scripting, Components, UE4, question\
**Created:** [March 6, 2015, 12:56am UTC](https://forums.unrealengine.com/t/access-blueprint-components-from-c/309523 "2015-03-06T00:56:33Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![LinFredriksson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LinFredriksson](https://forums.unrealengine.com/u/LinFredriksson)\
**Post date:** [March 6, 2015, 12:56am UTC](https://forums.unrealengine.com/t/access-blueprint-components-from-c/309523/1 "2015-03-06T00:56:33Z")

</div>

Hi.

I am working on a small plugin for the unreal editor and i need to have access a blueprints components from c++.

What I want is basically access to the variables in the components of the blueprint currently open in the blueprint viewer ( all the components in the blueprints component tab ).

So if I have, for example, a character blueprint containing a character movement component and a camera component I want to be able to access for example the “field of view” float value in the camera settings or the “Jump Z Velocity” float value in the character movement component from the c++ code.

Is this possible? I might add that i only want to read the values, not change any of them if that makes a difference.

I have access to the current blueprint as “UBlueprint\* bp” and from other questions here I read that if I have a Actor pointer it is possible to call GetComponents that will return a list of components, is this what I am looking for? and if it is, how do I use this with my UBlueprint pointer?

Many thanks in advance.

---

<div class="post-metadata">

**Author:** ![MickD777](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MickD777](https://forums.unrealengine.com/u/MickD777)\
**Post date:** [March 6, 2015, 1:56am UTC](https://forums.unrealengine.com/t/access-blueprint-components-from-c/309523/2 "2015-03-06T01:56:48Z")

</div>

The correct way to do this would be to first create a C++ class, than create a blueprint from that class.

For example, you create a class names ClassA. You specify that class to be Blueprintable by using the Blueprintable specifier in the UCLASS macro when defining your class.

Then, in the editor create your Blueprint from ClassA. Let’s call it ClassA\_BP for this example.

One way to do it would be to create your component (like your movement component) directly in the C++ class using the ObjectInitializer (Or the PCIP if you are on a version of Unreal earlier than 4.6). If you really want to create the components in your Blueprint and then “get” them in your C++, then yes, the way to go is to use GetComponents().

Something like this : (I’m writing from memory, so the syntax may be wrong)

```
TArray<UMoveComponents*> allMoveComp;
GetComponents<UMoveComponent>(allMoveComp);

for(int32 i = 0; i < allMoveComp.Num(); i++)
{
    //Do whaterver you want here with the components...
}
```

---

<div class="post-metadata">

**Author:** ![LinFredriksson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LinFredriksson](https://forums.unrealengine.com/u/LinFredriksson)\
**Post date:** [March 7, 2015, 2:48am UTC](https://forums.unrealengine.com/t/access-blueprint-components-from-c/309523/3 "2015-03-07T02:48:59Z")

</div>

The plugin should work with any blueprint so i do need to create the components in the blueprint and then get them in C++. So then GetComponents() is what i want, great. But if I have a blueprint pointer how can i use this function? If I have a character blueprint, how do I get a AActor from that I can use to call GetComponents() ?

---

<div class="post-metadata">

**Author:** ![kamrann](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kamrann](https://forums.unrealengine.com/u/kamrann)\
**Post date:** [March 7, 2015, 9:26am UTC](https://forums.unrealengine.com/t/access-blueprint-components-from-c/309523/4 "2015-03-07T09:26:25Z")

</div>

I’m not certain this is the correct way, but I’d try getting the CDO as follows:

```
Blueprint->GeneratedClass->GetDefaultObject< AActor >() ;

```

Hopefully, if it’s an actor blueprint, that should return a valid pointer to the default object for the blueprint’s class, from which you can access the values.

---

<div class="post-metadata">

**Author:** ![LinFredriksson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LinFredriksson](https://forums.unrealengine.com/u/LinFredriksson)\
**Post date:** [March 9, 2015, 3:03pm UTC](https://forums.unrealengine.com/t/access-blueprint-components-from-c/309523/5 "2015-03-09T15:03:45Z")

</div>

Yes, this does give me all the default components, so it is a big step in the right direction. But i need to access all of the components in the current blueprint not only the default components and i have not yet figured out how to do this. Then off course i need to figure out how to access the values inside of these components, but one step at a time for now.

---

<div class="post-metadata">

**Author:** ![kamrann](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kamrann](https://forums.unrealengine.com/u/kamrann)\
**Post date:** [March 9, 2015, 9:58pm UTC](https://forums.unrealengine.com/t/access-blueprint-components-from-c/309523/6 "2015-03-09T21:58:15Z")

</div>

I’m not sure what you mean by ‘default’ components. I haven’t tested it, but the CDO for a blueprint should have all components which you can see in the components tab instantiated for it. Then you can access their values by either casting, or, if you don’t want to make any assumptions about the types of components, you can call GetClass() and then iterate over the properties.

You might also need to be aware that the CDO will only reflect the state of the blueprint at the point it was last compiled.

---

<div class="post-metadata">

**Author:** ![LinFredriksson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LinFredriksson](https://forums.unrealengine.com/u/LinFredriksson)\
**Post date:** [March 10, 2015, 12:28am UTC](https://forums.unrealengine.com/t/access-blueprint-components-from-c/309523/7 "2015-03-10T00:28:57Z")

</div>

With ‘default’ components I meant the components that exist by default when I create for example a character blueprint. Any components i added later to the blueprint did not show up. But i figured out how to find those components in another day. I also managed to access the values so now I think that I have everything I needed. Thanks for the answer.

---

<div class="post-metadata">

**Author:** ![zamy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zamy](https://forums.unrealengine.com/u/zamy)\
**Post date:** [April 22, 2015, 3:10pm UTC](https://forums.unrealengine.com/t/access-blueprint-components-from-c/309523/8 "2015-04-22T15:10:52Z")

</div>

How did you do that man? i’m stuck on this too. Any suggestions?

---

<div class="post-metadata">

**Author:** ![phil.harlow](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@phil.harlow](https://forums.unrealengine.com/u/phil.harlow)\
**Post date:** [September 16, 2016, 9:43pm UTC](https://forums.unrealengine.com/t/access-blueprint-components-from-c/309523/9 "2016-09-16T21:43:01Z")

</div>

I am also looking for a solution to this. Could you share the workaround you found?

Thanks!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b24d331](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b24d331](https://forums.unrealengine.com/u/anonymous_user_4b24d331)\
**Post date:** [August 10, 2018, 12:10pm UTC](https://forums.unrealengine.com/t/access-blueprint-components-from-c/309523/10 "2018-08-10T12:10:23Z")

</div>

While the asset is being edited, you might have luck accessing the editor’s preview instance using `Blueprint->SimpleConstructionScript->GetComponentEditorActorInstance()`

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_6b44c8a2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6b44c8a2](https://forums.unrealengine.com/u/anonymous_user_6b44c8a2)\
**Post date:** [September 19, 2022, 10:56am UTC](https://forums.unrealengine.com/t/access-blueprint-components-from-c/309523/11 "2022-09-19T10:56:37Z")

</div>

I find a solution, hope it’s useful to you

> UIntProperty\* Prop;  
> Prop = FindFieldChecked(component-\>GetClass(), “PropName”);  
> int PropName = Prop-\>GetPropertyValue\_InContainer(component);

---

<div class="post-metadata">

**Author:** ![Dante\_farate](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dante\_farate](https://forums.unrealengine.com/u/Dante_farate)\
**Post date:** [November 26, 2025, 4:27pm UTC](https://forums.unrealengine.com/t/access-blueprint-components-from-c/309523/12 "2025-11-26T16:27:05Z")

</div>

this works for me  
`template<typename T>`  
`static TArray<T*> GetComponentsFromBlueprint(const UBlueprint* Blueprint)`  
`{`  
` if (!Blueprint) return {};`  
` const UClass* GeneratedClass = Blueprint->GeneratedClass;`  
` if (!GeneratedClass) return {};`  
` const AActor* CDO = Cast<AActor>(GeneratedClass->GetDefaultObject());`  
` if (!ensure(CDO)) return {};`

` // Gather the initial components/SCS Nodes from this BP class.`  
` TArray<T*> MeshComponents;`  
` CDO->GetComponents<T>(MeshComponents);`  
` constexpr int32 InlineCapacity = 512;`  
` TArray<USCS_Node*, TInlineAllocator<InlineCapacity>> AllSCSNodes;`  
` if (const USimpleConstructionScript* SCS = Blueprint->SimpleConstructionScript)`  
` {`  
` AllSCSNodes.Append(SCS->GetAllNodes());`  
` }`  
` // Traverse the parent chain to gather SCS Nodes from parent BPs.`  
` UClass* ParentClass = Blueprint->ParentClass;`  
` while (ParentClass)`  
` {`  
` // If the parent is native (C++), we stop because CDO->GetComponents already caught those.`  
` const UBlueprintGeneratedClass* BPGC = Cast<UBlueprintGeneratedClass>(ParentClass);`  
` if (!BPGC) break;`

` if (const USimpleConstructionScript* ParentSCS = BPGC->SimpleConstructionScript)`  
` {`  
` AllSCSNodes.Append(ParentSCS->GetAllNodes());`  
` }`

` ParentClass = ParentClass->GetSuperClass();`  
` }`  
` // Process all gathered SCS Nodes to find components of the desired type.`  
` ensure(AllSCSNodes.Num() <= InlineCapacity);`  
` for (const USCS_Node* Node : AllSCSNodes)`  
` {`  
` if (!Node) continue;`  
` if (!Node->ComponentTemplate) continue;`  
` `  
` if (T* TemplateComponent = Cast<T>(Node->ComponentTemplate))`  
` {`  
` MeshComponents.AddUnique(TemplateComponent);`  
` }`  
` }`  
` return MeshComponents;`  
`}`
