# How to properly initialize a Custom Actor in C++

**URL:** <https://forums.unrealengine.com/t/how-to-properly-initialize-a-custom-actor-in-c/473040>\
**Category:** Asset Creation\
**Tags:** actor, constructors, unreal-engine, question\
**Created:** [October 16, 2020, 8:29pm UTC](https://forums.unrealengine.com/t/how-to-properly-initialize-a-custom-actor-in-c/473040 "2020-10-16T20:29:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![teutonicdesign](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@teutonicdesign](https://forums.unrealengine.com/u/teutonicdesign)\
**Post date:** [October 16, 2020, 8:29pm UTC](https://forums.unrealengine.com/t/how-to-properly-initialize-a-custom-actor-in-c/473040/1 "2020-10-16T20:29:06Z")

</div>

Hi community members,

I’m having trouble initializing my custom actor in C++. How do you attach skeletal mesh? The DefaultSceneRoot was also not showing in my BP child class of this actor. Sorry I’m still very new to UE4 C++.

Thanks a lot for helping!

.h

```
#include "CoreMinimal.h"
#include "Projectile.h"
#include "Arrow.generated.h"

/**
 * 
 */
UCLASS()
class RENOVA_API AArrow : public AProjectile
{
	GENERATED_BODY()

public:
	// Sets default values for this actor's properties
	AArrow();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
	class USkeletalMeshComponent* ArrowMesh;
	
	
};

```

.cpp

```
#include "Arrow.h"
#include "UObject/ConstructorHelpers.h"
#include "Components/SkeletalMeshComponent.h"

// Sets default values
AArrow::AArrow()
{
	// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	ArrowMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("ArrowMesh"));
	ArrowMesh->SetupAttachment(RootComponent);
	static ConstructorHelpers::FObjectFinder<USkeletalMesh> ArrowMeshAsset(TEXT("/Game/Models/ClassWeapons/arrow_model"));

}
```

---

<div class="post-metadata">

**Author:** ![Detach789](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Detach789](https://forums.unrealengine.com/u/Detach789)\
**Post date:** [October 16, 2020, 8:41pm UTC](https://forums.unrealengine.com/t/how-to-properly-initialize-a-custom-actor-in-c/473040/2 "2020-10-16T20:41:34Z")

</div>

Try typing:

UPROPERTY()

class USkeletalMeshComponent\* ArrowMesh;

into the header class somewhere.

If that doesn’t fix it, then I’m not sure what the problem could be.

---

<div class="post-metadata">

**Author:** ![teutonicdesign](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@teutonicdesign](https://forums.unrealengine.com/u/teutonicdesign)\
**Post date:** [October 20, 2020, 2:29pm UTC](https://forums.unrealengine.com/t/how-to-properly-initialize-a-custom-actor-in-c/473040/3 "2020-10-20T14:29:15Z")

</div>

Thanks! I think what I need was also included in this doc. Just didn’t know that you need to create an object such as sphere component and set “RootComponent = SphereComponent” 🙂  
[https://docs.unrealengine.com/en-US/Programming/Tutorials/Components/1/index.html](https://docs.unrealengine.com/en-US/Programming/Tutorials/Components/1/index.html)
