# StaticMesh can not be moved

**URL:** <https://forums.unrealengine.com/t/staticmesh-can-not-be-moved/295834>\
**Category:** C++\
**Tags:** staticmeshcomponent, scenecomponent, unreal-engine, CPP, question\
**Created:** [October 10, 2014, 10:32pm UTC](https://forums.unrealengine.com/t/staticmesh-can-not-be-moved/295834 "2014-10-10T22:32:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_e13770ab](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e13770ab](https://forums.unrealengine.com/u/anonymous_user_e13770ab)\
**Post date:** [October 10, 2014, 10:32pm UTC](https://forums.unrealengine.com/t/staticmesh-can-not-be-moved/295834/1 "2014-10-10T22:32:30Z")

</div>

Hey guys,  
I have a class, that is inherited from AActor.  
In this class, I added a StaticMeshComponent and a SceneComponent.  
The SceneComponent should allow a class instance to be moved, right?  
The StaticMesh, however, always stays at the same position, no matter where I move the SceneComponent.  
Here is my code in the header file:

```
UPROPERTY(VisibleAnywhere, Category = "Dungeon")
		TSubobjectPtr<UStaticMeshComponent> roomMesh;

	UPROPERTY(VisibleAnywhere, Category = "Dungeon")
		TSubobjectPtr<USceneComponent> sceneComp;

```

and here is, what I did in the constructor in order to be able to move the Mesh (at least I thought that):

```
sceneComp = PCIP.CreateDefaultSubobject<USceneComponent>(this, TEXT("scene"));
	RootComponent = sceneComp;
	roomMesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("mesh"));
	roomMesh->AttachTo(sceneComp);

```

I am sure this is just a very simple problem, but I can’t find the correct answer.  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e13770ab](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e13770ab](https://forums.unrealengine.com/u/anonymous_user_e13770ab)\
**Post date:** [October 10, 2014, 11:53pm UTC](https://forums.unrealengine.com/t/staticmesh-can-not-be-moved/295834/2 "2014-10-10T23:53:27Z")

</div>

Ok I got it.  
This is quite stupid, but as soon as I swapped the lines in the header file (declaring the sceneComponent first) it works like a charm.  
This might be a bug, so probably somebody should look into this.  
However, problem solved.
