# Cant add StaticMeshComponent derived class to BP actor

**URL:** <https://forums.unrealengine.com/t/cant-add-staticmeshcomponent-derived-class-to-bp-actor/425875>\
**Category:** Blueprint\
**Tags:** staticmeshcomponent, unreal-engine, bug-report, Blueprint, CPP, question\
**Created:** [May 24, 2018, 5:52pm UTC](https://forums.unrealengine.com/t/cant-add-staticmeshcomponent-derived-class-to-bp-actor/425875 "2018-05-24T17:52:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_0358ed391](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0358ed391](https://forums.unrealengine.com/u/anonymous_user_0358ed391)\
**Post date:** [May 24, 2018, 5:52pm UTC](https://forums.unrealengine.com/t/cant-add-staticmeshcomponent-derived-class-to-bp-actor/425875/1 "2018-05-24T17:52:52Z")

</div>

I have created a custom class that derives from “UStaticMeshComponent” and adds some “controll”-features  
and a MaterialInstance (Its a light, that can be turned on and off)

Everything compiles

If i try to move the class from the ContentBrowser (Source Folder) to my Blueprint-Actor it wont add an object of the class to the actor,  
there is no “red cross” or anything else, that would tell me, that im not allowed to add it, so it seems like a bug for me.

Is it not allowed to add a StaticMeshComponent derived class to a BP actor or am I missing something else?

---

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [May 25, 2018, 5:18am UTC](https://forums.unrealengine.com/t/cant-add-staticmeshcomponent-derived-class-to-bp-actor/425875/2 "2018-05-25T05:18:32Z")

</div>

did you tried to add it using “AddComponent” menu in blueprint editor? Is it appears there?

---

<div class="post-metadata">

**Author:** ![de\_lay.dsp](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@de\_lay.dsp](https://forums.unrealengine.com/u/de_lay.dsp)\
**Post date:** [May 25, 2018, 6:39am UTC](https://forums.unrealengine.com/t/cant-add-staticmeshcomponent-derived-class-to-bp-actor/425875/3 "2018-05-25T06:39:10Z")

</div>

Hopefully I have understood the question.

Within your Blueprint Actor class you need to ‘Add Component’ and then select ‘Static Mesh’. After that on the right hand side there will be a static mesh drop down menu and a green box with ‘none’ written inside it. Click on that and select the static mesh you want to add.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0358ed391](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0358ed391](https://forums.unrealengine.com/u/anonymous_user_0358ed391)\
**Post date:** [May 25, 2018, 2:17pm UTC](https://forums.unrealengine.com/t/cant-add-staticmeshcomponent-derived-class-to-bp-actor/425875/4 "2018-05-25T14:17:14Z")

</div>

No, it doesn’t show, could posting the source code help, maybe im missing something…

#pragma once

#include “CoreMinimal.h”  
#include “Components/StaticMeshComponent.h”  
#include “TrainLight.generated.h”

UCLASS(BlueprintType)  
class METRO2\_API UTrainLight : public UStaticMeshComponent  
{  
GENERATED\_BODY()

```
UTrainLight();

```

#if WITH\_EDITOR  
void PostEditChangeProperty(struct FPropertyChangedEvent& e);  
#endif

public:

```
void TurnOn(bool AsFrontLight = false);
void TurnOff();

bool IsFrontLight() {return bFrontLight;}
bool IsBackLight() {return bBackLight;}

```

private:

```
UPROPERTY(EditAnywhere)
bool bFrontLight = false;

UPROPERTY(EditAnywhere)
bool bBackLight = false;

UMaterialInstanceDynamic* MI_Light;

```

};

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0358ed391](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0358ed391](https://forums.unrealengine.com/u/anonymous_user_0358ed391)\
**Post date:** [May 25, 2018, 2:19pm UTC](https://forums.unrealengine.com/t/cant-add-staticmeshcomponent-derived-class-to-bp-actor/425875/5 "2018-05-25T14:19:10Z")

</div>

That would be fine if i wanted to add a blank StaticMeshComponent, but I want my custom class, that inherits from UStaticMeshComponent, see the code I posted above

---

<div class="post-metadata">

**Author:** ![Jawdy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jawdy](https://forums.unrealengine.com/u/Jawdy)\
**Post date:** [May 25, 2018, 2:37pm UTC](https://forums.unrealengine.com/t/cant-add-staticmeshcomponent-derived-class-to-bp-actor/425875/6 "2018-05-25T14:37:28Z")

</div>

For the UCLASS Macro, I use the following:

```
UCLASS( ClassGroup = ( CustomGroupName ), meta = ( BlueprintSpawnableComponent ) )

```

That then allows for the Component to appear in the editor.

If you’re wanting any of your functions to be usable in the Editor via Blueprints, you’ll need to make sure you use the UFUNCTION() macro.

And I would recommend still adding a UPROPERTY() macro ahead of your UMaterialInstanceDynamic declaration, just in case it doesn’t get GC’d out from under you! You can use it with no params, so it’ll be included in UBT, but not visible/editable in BPs.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0358ed391](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0358ed391](https://forums.unrealengine.com/u/anonymous_user_0358ed391)\
**Post date:** [May 25, 2018, 6:15pm UTC](https://forums.unrealengine.com/t/cant-add-staticmeshcomponent-derived-class-to-bp-actor/425875/7 "2018-05-25T18:15:24Z")

</div>

Works great, thank you very much, but I still feel like Unreal could indicate such things a little bit more, because there was no feedback when I moved it from the content browser,

Anyways, thanks for your answer 🙂
