# Static mesh component in constructor behaving unexpectedly

**URL:** <https://forums.unrealengine.com/t/static-mesh-component-in-constructor-behaving-unexpectedly/426331>\
**Category:** Asset Creation\
**Tags:** scene-component, constructors, unreal-engine, editor, CPP, question\
**Created:** [May 31, 2018, 3:24am UTC](https://forums.unrealengine.com/t/static-mesh-component-in-constructor-behaving-unexpectedly/426331 "2018-05-31T03:24:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_06d1818e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_06d1818e](https://forums.unrealengine.com/u/anonymous_user_06d1818e)\
**Post date:** [May 31, 2018, 3:24am UTC](https://forums.unrealengine.com/t/static-mesh-component-in-constructor-behaving-unexpectedly/426331/1 "2018-05-31T03:24:12Z")

</div>

When I create my SceneComponent and attach it to an actor, I can see the arrow component and, when I move my SceneComponent, the arrow moves with it.

When I do the same thing for the static mesh component, I must set it in editor as if I did not CreateDefaultSubobject, and when I move the scene component, I see no motion for the static mesh.

Debugging in VS shows that the EyeMesh is non null after creation. When inspecting the children of my SceneComponent, I can see that EyeMesh is an attached child.

Header

```
 #pragma once
    
    #include "CoreMinimal.h"
    #include "Components/SceneComponent.h"
    #include "Components/ArrowComponent.h"
    ...
    #include "Components/StaticMeshComponent.h"
    #include "SC_2DEye.generated.h"
    
    UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
    class SB_CELSHADING_API USC_2DEye : public USceneComponent
    {
    	GENERATED_BODY()
    
    public:	
    	// Sets default values for this component's properties
    	USC_2DEye();
    
    	UPROPERTY()
    		UArrowComponent* m_eyeArrow;
    
    	UPROPERTY(EditAnywhere)
    		UStaticMeshComponent* EyeMesh;
    
    ...
    }

```

CPP

```
USC_2DEye::USC_2DEye()
{
	if (IsTemplate())
	{
		return;
	}
	
	PrimaryComponentTick.bCanEverTick = true;

		m_eyeArrow = CreateDefaultSubobject<UArrowComponent>(TEXT("EyeDirection3D"));
		m_eyeArrow->SetupAttachment(this);

		EyeMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("EyeMesh"));
		EyeMesh->SetMobility(EComponentMobility::Movable);
		EyeMesh->SetupAttachment(this);
}

```

---

<div class="post-metadata">

**Author:** ![mesterKG](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mesterKG](https://forums.unrealengine.com/u/mesterKG)\
**Post date:** [October 5, 2018, 6:48pm UTC](https://forums.unrealengine.com/t/static-mesh-component-in-constructor-behaving-unexpectedly/426331/2 "2018-10-05T18:48:43Z")

</div>

Use VisibleAnywhere instead of EditAnywhere for the EyeMesh property and you should be good to go.
