Creating a Particle Module

I was following this tutorial on creating a particle module and wanted to report some problems with it.

Non-exposed API

Firstly, as noted in this question, you can’t write your own particle modules as the relevant classes are not in the public facing API. I don’t know if there is a good reason for this, but it certainly should be noted in the tutorial.

BTW, this is a massive pain. I had hoped to create a plugin with some boid particle modules, but requiring people to change the engine makes this not feasible. It is a major limitation and annoyance.

Missing Include

Also pointed out in that question, the CPP file needs to #include "ParticleEmitterInstances.h".

Wrong Header File Code Sample

Secondly, the code sample provided for the header is not even valid C++. Instead it should read:

UCLASS(editinlinenew, collapsecategories, hidecategories = Object)
class BOIDPARTICLES_API UParticleModuleColourByVelocity : public UParticleModuleColorBase
{
	GENERATED_BODY()
public:
	UParticleModuleColourByVelocity(const FObjectInitializer& PCIP);

	UPROPERTY(EditAnywhere, Category = Color)
	struct FRawDistributionVector ScaleVelocity;

	virtual void Spawn(FParticleEmitterInstance* Owner, int32 Offset, float SpawnTime, FBaseParticle* ParticleBase);

	virtual void Update(FParticleEmitterInstance* Owner, int32 Offset, float DeltaTime);	
};

Crucially, the UPROPERY decoration rather than the presumably old-style var stuff.

Wrong Source File Code Sample

Further, in the constructor body, instead of using the non-existent ConstructorHelpers::CreateDefaultSubobject it should use PCIP.CreateDefaultSubobject(this, TEXT("DistributionScaleVelocity")); where PCIP is the FObjectInitializer passed in the constructor.

No GPU Explanation

Finally, the tutorial goes in to no detail about how to make the module work on the GPU, perhaps because it isn’t possible in general. In any case, it should be explicitly explained.