C++ Spawning Decals from Niagara particle collisions

Hiya. I know the standard procedure for getting decals to spawn from niagara particle collisions is by using this event

image

and also the “Export particle data to blueprint”

How would I achieve a similar setup in c++? I can’t seem to find anything relating to exporting data for UNiagaraComponent.

To handle the exported particle data in C++ you will need to define a class deriving from UObject that implements the INiagaraParticleCallbackHandler interface.

UCLASS()
class MyNiagaraParticleCallbackHandler : public UObject, public INiagaraParticleCallbackHandler
{
	GENERATED_BODY()
public:
	UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Niagara")
	void ReceiveParticleData(const TArray<FBasicParticleData>& Data, UNiagaraSystem* NiagaraSystem, const FVector& SimulationPositionOffset);
	virtual void ReceiveParticleData_Implementation(const TArray<FBasicParticleData>& Data, UNiagaraSystem* NiagaraSystem, const FVector& SimulationPositionOffset) override;
};

The class can then be instantiated and piped to the Niagara System via User Parameter and subsequently linked to the Callback Handler parameter in the “Export Particle Data to Blueprint” module.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.