Create Components in C++¶
Create new C++ class QuestMarker as a subclass of an Actor
Go to BP_QuestMarker and re-parent to QuestMarker
To avoid conflict, rename subcomponent ParticleSystem in Blueprint to BP_ParticleSystem.
Add the following to QuestMarker.h
Include:
#include "Particles/ParticleSystemComponent.h"
And add propoerties:
protected:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
USceneComponent* Root;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
UParticleSystemComponent* ParticleSystem;
};
Add the following to QuestMarker.cpp
AQuestMarker::AQuestMarker()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
Root = CreateDefaultSubobject<USceneComponent>(TEXT("SceneRoot"));
// Can only be used in constructor
ParticleSystem = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("ParticleSystem"));
SetRootComponent(Root);
ParticleSystem->SetupAttachment(Root);
}
Note that due to some strange cachinng problem you’ll need to restart UE4, rename ParticleSystem to ParticleSystem1 and rename it back to ParticleSystem again
From UE4 Editor, copy and paste all the properties from BP_ParticleSystem to ParticleSystem
Find references to BP_ParticleSystem and replace them with ParticleSystem
Delete BP_ParticleSystem