How to properly initialize a Custom Actor in C++

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!


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

class RENOVA_API AArrow : public AProjectile

	// Sets default values for this actor's properties

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

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

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


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

// Sets default values
	// 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"));
	static ConstructorHelpers::FObjectFinder<USkeletalMesh> ArrowMeshAsset(TEXT("/Game/Models/ClassWeapons/arrow_model"));


Try typing:


class USkeletalMeshComponent* ArrowMesh;

into the header class somewhere.

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

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” :slight_smile: