# Developing Particle Module

**URL:** <https://forums.unrealengine.com/t/developing-particle-module/308641>\
**Category:** FX\
**Tags:** unreal-engine, CPP, question\
**Created:** [March 1, 2015, 9:12pm UTC](https://forums.unrealengine.com/t/developing-particle-module/308641 "2015-03-01T21:12:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dale\_z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dale\_z](https://forums.unrealengine.com/u/dale_z)\
**Post date:** [March 1, 2015, 9:12pm UTC](https://forums.unrealengine.com/t/developing-particle-module/308641/1 "2015-03-01T21:12:51Z")

</div>

Hello,

I am following the steps on [Particle Module Technical Guide](https://docs.unrealengine.com/latest/INT/Programming/Rendering/ParticleModules/index.html) to create a cusotomized particle module in C++.

I started out with the Add Code wizard (in UE 4.7.1) and chose `ParticleModuleColor` as the base class (since `ParticleModuleColorBase` was for some reasone not selectable) and named the new class `MyParticleModuleColor`. Then when the new classes were being created an error message popped up:

`Failed to add class MyParticleModuleColor. Failed to automatically hot reload the MyCppTestProject module.`

But the `.h` and `.cpp` files had already been created despite the error message. So I went to VS 2013 and tried to build the project and got the errors:

```
1>------ Build started: Project: MyCppTestProject, Configuration: Development_Editor x64 ------
2>------ Skipped Build: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
2>Project not selected to build for this solution configuration 
1> Compiling game modules for hot reload
1> Performing 3 actions (4 in parallel)
1> MyParticleModuleColor.cpp
1> MyCppTestProject.generated.cpp
1>C:\Program Files\Epic Games\4.7\Engine\Source\Runtime\Engine\Classes\Particles/ParticleModule.h(372): error C2061: syntax error : identifier 'UDistributionFloat'C:\Program Files\Epic Games\4.7\Engine\Source\Runtime\Engine\Classes\Particles/ParticleModule.h(372) : error C2061: syntax error : identifier 'UDistributionFloat'
1>  
1>C:\Program Files\Epic Games\4.7\Engine\Source\Runtime\Engine\Classes\Particles/ParticleModule.h(382): error C2061: syntax error : identifier 'UDistributionVector'
1>C:\Program Files\Epic Games\4.7\Engine\Source\Runtime\Engine\Classes\Particles/ParticleModule.h(382): error C2061: syntax error : identifier 'UDistributionVector'
1>C:\Program Files\Epic Games\4.7\Engine\Source\Runtime\Engine\Classes\Particles/ParticleModule.h(580): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Epic Games\4.7\Engine\Source\Runtime\Engine\Classes\Particles/ParticleModule.h(580): error C2143: syntax error : missing ',' before '*'
1>C:\Program Files\Epic Games\4.7\Engine\Source\Runtime\Engine\Classes\Particles/ParticleModule.h(580): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Epic Games\4.7\Engine\Source\Runtime\Engine\Classes\Particles/ParticleModule.h(580): error C2143: syntax error : missing ',' before '*'
1>C:\Program Files\Epic Games\4.7\Engine\Source\Runtime\Engine\Classes\Particles/Color/ParticleModuleColor.h(15): error C2079: 'UParticleModuleColor::StartColor' uses undefined struct 'FRawDistributionVector'
1>C:\Program Files\Epic Games\4.7\Engine\Source\Runtime\Engine\Classes\Particles/Color/ParticleModuleColor.h(19): error C2079: 'UParticleModuleColor::StartAlpha' uses undefined struct 'FRawDistributionFloat'
1>C:\Program Files\Epic Games\4.7\Engine\Source\Runtime\Engine\Classes\Particles/Color/ParticleModuleColor.h(15): error C2079: 'UParticleModuleColor::StartColor' uses undefined struct 'FRawDistributionVector'
1>C:\Program Files\Epic Games\4.7\Engine\Source\Runtime\Engine\Classes\Particles/Color/ParticleModuleColor.h(19): error C2079: 'UParticleModuleColor::StartAlpha' uses undefined struct 'FRawDistributionFloat'
1> -------- End Detailed Actions Stats -----------------------------------------------------------
1>ERROR : UBT error : Failed to produce item: C:\Users\Me\Documents\Unreal Projects\MyCppTestProject\Binaries\Win64\UE4Editor-MyCppTestProject-7247.dll
1> Cumulative action seconds (8 processors): 0.00 building projects, 0.80 compiling, 0.00 creating app bundles, 0.00 generating debug info, 0.00 linking, 0.00 other
1> UBT execution time: 4.14 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ""C:\Program Files\Epic Games\4.7\Engine\Build\BatchFiles\Build.bat" MyCppTestProjectEditor Win64 Development "C:\Users\Me\Documents\Unreal Projects\MyCppTestProject\MyCppTestProject.uproject" -rocket" exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========

```

Is there a way to fix the problems in UE Editor and VS? And why cannot `ParticleModuleColorBase` be selected as a base class?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![HypnosisDigital](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HypnosisDigital](https://forums.unrealengine.com/u/HypnosisDigital)\
**Post date:** [March 5, 2015, 11:57pm UTC](https://forums.unrealengine.com/t/developing-particle-module/308641/2 "2015-03-05T23:57:43Z")

</div>

Hi there team at Epic!  
I’ve been experiencing this particular issue as well. I’m using perforce, and I think that is a part of the equation. Please let us know at your earliest convenience whether this is a bug or if there is a tricky way around it that we haven’t quite figure out.

You guys are awesome, and I love your work, keep it up!

---

<div class="post-metadata">

**Author:** ![Pierdek](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pierdek](https://forums.unrealengine.com/u/Pierdek)\
**Post date:** [March 6, 2015, 8:23am UTC](https://forums.unrealengine.com/t/developing-particle-module/308641/3 "2015-03-06T08:23:51Z")

</div>

If you want to derive a particle module classes you have to export them from the engine DLL by adding ENGINE\_API modifier:

```
class ENGINE_API UParticleModuleColorBase : public UParticleModule

```

You have to add this too in the UParticleModule, additional in this class remove MinimalAPI:

```
UCLASS(editinlinenew, hidecategories=Object, abstract)
class ENGINE_API UParticleModule : public UObject

```

and by default some of the UParticleModule methods are marked with ENGINE\_API, remove ENGINE\_API modifier from them.

And remember to add:

```
#include "ParticleDefinitions.h"

```

in your derived ParticleModule cpp file.

Hope this will help you:)

Regards

Pierdek

---

<div class="post-metadata">

**Author:** ![dale\_z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dale\_z](https://forums.unrealengine.com/u/dale_z)\
**Post date:** [March 6, 2015, 4:24pm UTC](https://forums.unrealengine.com/t/developing-particle-module/308641/4 "2015-03-06T16:24:36Z")

</div>

Thank you, Pierdek! Your solution works for me - Exposing the classes from the engine’s source and referencing this modified version from a game project. Though in the future it is up to the UE team to decide whether to export these classes in release versions or not, for now this solution somehow maintains the independence of the added functionality from the engine.

As the discussion goes in another thread ([Adding new .h/.cpp files to engine source - Programming & Scripting - Epic Developer Community Forums](https://answers.unrealengine.com/questions/184806/add-new-hcpp-files-to-engine.html)), an alternative method would be adding the feature directly inside the engine without changing export modifiers.

Best regards,  
D

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_364d6e76](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_364d6e76](https://forums.unrealengine.com/u/anonymous_user_364d6e76)\
**Post date:** [May 23, 2015, 5:50pm UTC](https://forums.unrealengine.com/t/developing-particle-module/308641/5 "2015-05-23T17:50:30Z")

</div>

Hi,

I’ve been trying the same thing here and I must say I’m a little lost as to how to get this work.

I am following the and the generated result of this wizard doest compile. With much the same issues as in the first post here. I’m very new to C++ but have several years of C# experience. (not that thats helping)

I’ve no idea how to apply Pierdek’s suggestions here.

Do the changes you mention need to go in the UE4 code base or my game projects code?

The broken starting point that the wizard gives are:

MyParticleModuleColorTest.h:

```
#pragma once
#include "Particles/Color/ParticleModuleColor.h"
#include "MyParticleModuleColorTest.generated.h"

/**
 * 
 */
UCLASS()
class EFFECTSTESTER_API UMyParticleModuleColorTest : public UParticleModuleColor
{
	GENERATED_BODY()
};

```

and

MyParticleModuleColorTest.cpp:

```
#include "EffectsTester.h"
#include "MyParticleModuleColorTest.h"

```

Thanks in advance to anyone who can help here,

Regards

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_59e62692](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_59e62692](https://forums.unrealengine.com/u/anonymous_user_59e62692)\
**Post date:** [October 21, 2016, 2:07pm UTC](https://forums.unrealengine.com/t/developing-particle-module/308641/6 "2016-10-21T14:07:48Z")

</div>

Hi Epic. I would appreciate if it will be possible to extend particle modules in the game and not the engine itself. It is a hard restriction somehow.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_af7d4639](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_af7d4639](https://forums.unrealengine.com/u/anonymous_user_af7d4639)\
**Post date:** [March 6, 2018, 8:42pm UTC](https://forums.unrealengine.com/t/developing-particle-module/308641/7 "2018-03-06T20:42:43Z")

</div>

Can’t find the Particle Module Technical Guide in the Unreal documentation anymore. Does anyone know why they removed it?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d4aadacc1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d4aadacc1](https://forums.unrealengine.com/u/anonymous_user_d4aadacc1)\
**Post date:** [August 19, 2019, 3:24pm UTC](https://forums.unrealengine.com/t/developing-particle-module/308641/8 "2019-08-19T15:24:36Z")

</div>

Here is my way how to add particle module with out editing engine source (works for unreal 4.22)

First create abstract class which will tell engine category of your modules, let it be “Wind” group:

```
#pragma once

#include "CoreMinimal.h"
#include "Particles/ParticleModule.h"
#include "ParticleModuleWindBase.generated.h"

/**
 * 
 */
UCLASS(editinlinenew, hidecategories = Object, abstract, meta = (DisplayName = "Wind"))
class YOURAPP_API UParticleModuleWindBase : public UParticleModule
{
	GENERATED_BODY()
	
};

```

Then create class derived from this to implement actual behavior:

```
#pragma once

#include "CoreMinimal.h"
#include "ParticleModuleWindBase.h"
#include "ParticleDefinitions.h"
#include "ParticleModuleWind.generated.h"

/**
 * 
 */
UCLASS(editinlinenew, hidecategories = Object, meta = (DisplayName = "Constant velocity"))
class YOURAPP_API UParticleModuleWind : public UParticleModuleWindBase
{
	GENERATED_UCLASS_BODY()

	/**
	* How much wind affect particle [0-1]
	* 0 - particles not affected by wind
	* 1 - particle speed equal wind speed
	*/
	UPROPERTY(EditAnywhere, Category = Velocity)
	float Amount;

	/** Initializes the default values */
	void InitializeDefaults();

	//~ Begin UObject Interface
#if WITH_EDITOR
	virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif // WITH_EDITOR
	virtual void PostInitProperties() override;
	//~ End UObject Interface

	//~ Begin UParticleModule Interface
	virtual void Spawn(FParticleEmitterInstance* Owner, int32 Offset, float SpawnTime, FBaseParticle* ParticleBase) override;
	//~ Begin UParticleModule Interface

	/**
	*	Extended version of spawn, allows for using a random stream for distribution value retrieval
	*
	*	@param	Owner The particle emitter instance that is spawning
	*	@param	Offset The offset to the modules payload data
	*	@param	SpawnTime The time of the spawn
	*	@param	InRandomStream The random stream to use for retrieving random values
	*/
	void SpawnEx(FParticleEmitterInstance* Owner, int32 Offset, float SpawnTime, struct FRandomStream* InRandomStream, FBaseParticle* ParticleBase);
};

```

It will create new group in editor with single module “Constant velocity” available there
