Emitter Component Requests

The Emitter component requests bus is used to interact with a PopcornFX emitter component.
The bus is connected using the entity ID corresponding to the entity on which the PopcornFX emitter is attached.

Warning: Be careful, those events need the effect to be loaded and instantiated before being used!
The effect async loading and creation is triggered by the SetupEmitterByName or SetupEmitterById events.
You can check if the emitter has been created by:

  • Making sure IsLoaded() returns true

  • Use the PopcornFX requests bus and calling IsEffectsPreloadingDone() that will only return true if all effects have finished loading

  • Connect to the emitter component events bus and waiting for the OnFxCreated() callback

Return type

Description

void

`Enable(bool enable) `Enables or disables the current emitter. When the emitter is disabled, the particles are neither simulated or rendered anymore.

bool

Start()
Starts the particle emission on the current emitter.
Returns false if the effect is already started or still has some living particles.

bool

Stop()
Stops the particle emission on the current emitter. The particles that are still alive will continue getting the emitter instance transforms, so they will possibly continue following the emitter depending on how the effect was designed.
Returns false if the particle emission was already stopped.

bool

Terminate()
Stops the particle emission on the current emitter. The particles that are still alive will not get the emitter transforms anymore, as if the effect was detached from the entity when this is called.
Returns false if the particle emission was already stopped.

bool

Kill()
Stops the particle emission on the current emitter and kills all the particles that were emitted from this emitter instance.
Returns false if the particle emission was already stopped and if all the emitted particles from this emitter are already dead.

bool

Restart(bool killOnRestart)
Restarts the current effect.
If killOnRestart is false, the particle emission is stopped and the emitter is restarted when the last living particle dies.
If killOnRestart is true, the particle emission is stopped and all the living particles are killed. In this case the emitter is restarted immediately.

bool

IsLoaded()
Returns true when the effect is loaded, false otherwise.

bool

IsEnabled()
Returns true when the effect is enabled, false otherwise.

bool

IsPlaying()
Returns true when the effect is currently playing or still has some living particles.

bool

SetupEmitterById(const AZ::Data::AssetId &assetId, bool enable)
Setup the pkfx asset on this emitter component.
assetId is the identifier corresponding to the ".pkfx" effect asset.
enable enables or disables the current emitter.
Returns true if successful.

bool

SetupEmitterByName(const AZStd::string &path, bool enable)
Setup the pkfx asset on this emitter component.
path is the path to the ".pkfx" effect asset.
enable enables or disables the current emitter.
Returns true if successful.

void

SetVisible(bool visible)
Hides or shows the current emitter particles. Unlike the Enable(bool enable) function, the simulation is still runing, the particles are just not rendered.

bool

GetVisible()
Returns false if the emitter particles are hidden, true otherwise.

void

SetTimeScale(float timeScale)
Scales the simulation time for this emitter by the timeScale factor.
For example, if timeScale is 0.5f the effect will play twice as slow as normal.

float

GetTimeScale()
Returns the current time scale applied to this emitter component.

void

SetPrewarmEnable(bool enable)
Enables or disables the effect prewarm. Prewarming is used to start the effect at a certain point in time, so the effect looks like it has been simulated during a defined time when it is started.

bool

GetPrewarmEnable()
Returns true if prewarm was enabled for this emitter.

void

SetPrewarmTime(float time)
Sets the prewarm time. If prewarm is enabled, the effect will look like it was simulated during time seconds as soon as it is started.

float

GetPrewarmTime()
Returns the prewarm time that was set for this emitter.

AZ::u32

GetAttributesCount()
Returns the total number of attributes for this emitter. This does not include the samplers.

AZStd::string

GetAttributeName(AZ::u32 attribId)
Return the attribute name from its index attribId.
If attribId is invalid, returns an empty string.

AZ::s32

GetAttributeType(AZ::u32 attribId)
Returns the attribute type from its index attribId.
The return value can be one of the following (see the EPopcornFXType enum in PopcornFXBus.h):
-1: Type_Unknown Invalid type
0: Type_Bool Boolean value
1: Type_Bool2 Vector2 boolean value
2: Type_Bool3 Vector3 boolean value
3: Type_Bool4 Vector4 boolean value
4: Type_Float Floating point value
5: Type_Float2 Vector2 floating point value
6: Type_Float3 Vector3 floating point value
7: Type_Float4 Vector4 floating point value
8: Type_Int Integer value
9: Type_Int2 Vector2 integer value
10: Type_Int3 Vector3 integer value
11: Type_Int4 Vector4 integer value
12: Type_Quaternion Quaternion orientation value

AZ::s32

GetAttributeId(const AZStd::string &name)
Returns the index of the attribute based on the name parameter. If no attribute with this name exists, returns -1.

bool

ResetAttributeToDefault(AZ::u32 attribId)
Resets the attribute at index attribId to its default value.
Returns false if attribId is invalid.

bool

SetAttributeAsFloat(AZ::u32 attribId, float value)
Sets a floating point attribute.
Returns false if attribId is invalid or if the attribute is not of type float.

bool

SetAttributeAsFloat2(AZ::u32 attribId, const AZ::Vector2 &value)
Sets a vector2 float attribute.
Returns false if attribId is invalid or if the attribute is not of type float2.

bool

SetAttributeAsFloat3(AZ::u32 attribId, const AZ::Vector3 &value)
Sets a vector3 float attribute.
Returns false if attribId is invalid or if the attribute is not of type float3.

bool

SetAttributeAsFloat4(AZ::u32 attribId, const AZ::Vector4 &value)
Sets a vector4 float attribute.
Returns false if attribId is invalid or if the attribute is not of type float4.

bool

SetAttributeAsInt(AZ::u32 attribId, AZ::s32 value)
Sets a integer attribute.
Returns false if attribId is invalid or if the attribute is not of type int.

bool

SetAttributeAsInt2(AZ::u32 attribId, AZ::s32 valueX, AZ::s32 valueY)
Sets a vector2 integer attribute.
Returns false if attribId is invalid or if the attribute is not of type int2.

bool

SetAttributeAsInt3(AZ::u32 attribId, AZ::s32 valueX, AZ::s32 valueY, AZ::s32 valueZ)
Sets a vector3 integer attribute.
Returns false if attribId is invalid or if the attribute is not of type int3.

bool

SetAttributeAsInt4(AZ::u32 attribId, AZ::s32 valueX, AZ::s32 valueY, AZ::s32 valueZ, AZ::s32 valueW)
Sets a vector4 integer attribute.
Returns false if attribId is invalid or if the attribute is not of type int4.

bool

SetAttributeAsBool(AZ::u32 attribId, bool value)
Sets a boolean attribute.
Returns false if attribId is invalid or if the attribute is not of type bool.

bool

SetAttributeAsBool2(AZ::u32 attribId, bool valueX, bool valueY)
Sets a vector2 boolean attribute.
Returns false if attribId is invalid or if the attribute is not of type bool2.

bool

SetAttributeAsBool3(AZ::u32 attribId, bool valueX, bool valueY, bool valueZ)
Sets a vector3 boolean attribute.
Returns false if attribId is invalid or if the attribute is not of type bool3.

bool

SetAttributeAsBool4(AZ::u32 attribId, bool valueX, bool valueY, bool valueZ, bool valueW)
Sets a vector4 boolean attribute.
Returns false if attribId is invalid or if the attribute is not of type bool4.

bool

SetAttributeAsQuaternion(AZ::u32 attribId, const AZ::Quaternion &value)
Sets a quaternion attribute.
Returns false if attribId is invalid or if the attribute is not of type quaternion.

bool

SetAttributeAsColor(AZ::u32 attribId, const AZ::Color &value)
Sets a color attribute.
Returns false if attribId is invalid or if the attribute is not of type float3 or float4.

float

GetAttributeAsFloat(AZ::u32 attribId)
Returns the value of the attribute at index attribId or 0.0f if attribId is invalid.

AZ::Vector2

GetAttributeAsFloat2(AZ::u32 attribId)
Returns the value of the attribute at index attribId or an uninitialized AZ::Vector2 if attribId is invalid.

AZ::Vector3

GetAttributeAsFloat3(AZ::u32 attribId)
Returns the value of the attribute at index attribId or an uninitialized AZ::Vector3 if attribId is invalid.

AZ::Vector4

GetAttributeAsFloat4(AZ::u32 attribId)
Returns the value of the attribute at index attribId or an uninitialized AZ::Vector4 if attribId is invalid.

AZ::s32

GetAttributeXAsInt(AZ::u32 attribId)
Returns the value of the first attribute component at index attribId or -1 if attribId is invalid.

AZ::s32

GetAttributeYAsInt(AZ::u32 attribId)
Returns the value of the second attribute component at index attribId or -1 if attribId is invalid.

AZ::s32

GetAttributeZAsInt(AZ::u32 attribId)
Returns the value of the third attribute component at index attribId or -1 if attribId is invalid.

AZ::s32

GetAttributeWAsInt(AZ::u32 attribId)
Returns the value of the fourth attribute component at index attribId or -1 if attribId is invalid.

bool

GetAttributeXAsBool(AZ::u32 attribId)
Returns the value of the first attribute component at index attribId or false if attribId is invalid.

bool

GetAttributeYAsBool(AZ::u32 attribId)
Returns the value of the second attribute component at index attribId or false if attribId is invalid.

bool

GetAttributeZAsBool(AZ::u32 attribId)
Returns the value of the third attribute component at index attribId or false if attribId is invalid.

bool

GetAttributeWAsBool(AZ::u32 attribId)
Returns the value of the fourth attribute component at index attribId or false if attribId is invalid.

AZ::Quaternion

GetAttributeAsQuaternion(AZ::u32 attribId)
Returns the value of the attribute at index attribId or AZ::Quaternion::CreateIdentity() if attribId is invalid.

AZ::Color

GetAttributeAsColor(AZ::u32 attribId)
Returns the value of the attribute at index attribId or an uninitialized value if attribId is invalid.

AZ::u32

GetAttributeSamplersCount()
Returns the total number of attribute samplers for this emitter.

AZ::s32

GetAttributeSamplerId(const AZStd::string &name)
Returns the index of the attribute sampler based on the name parameter. If no attribute sampler with this name exists, returns -1.

bool

SetAttributeSampler(AZ::u32 attribSamplerId, AZ::EntityId entityId)
Sets the attribute sampler at index attribSamplerId to the sampler component attached to the entity identified by entityId.
The effect needs to be stopped for this to work.
Returns false if attribSamplerId is invalid, if the effect is currently playing or if the sampler component attached to the target entity is not the same type as the emitter sampler.

bool

ResetSamplerToDefault(AZ::u32 attribSamplerId)
Resets the attribute at index attribSamplerId`to its default value.
Returns `false
if attribSamplerId is invalid.

AZ::EntityId

GetAttributeSampler(AZ::u32 attribSamplerId)
Returns the AZ::EntityId to which the attribute sampler at index attribSamplerId is attached to.
Returns AZ::EntityId::InvalidEntityId if attribSamplerId is invalid.

void

SetTeleportThisFrame()
Notify the emitter that the entity will be teleported to another place this frame.
This avoids spawning many particles when the emitter is using distance based particle emission.