Skip to content
ParticleEmitter

Scene / ParticleEmitter

ParticleEmitter Class

Particle effect

It is usually used for the effect performance in the scene of the game. At present, some particle effects are open. When the editor details panel checks Auto enable, the running game will automatically play the effect.

To precisely control the playback and stop of special effects, please use the play and stop methods. This special effect requires manual control of its lifecycle, and the effect can be adjusted through parameters in the details panel.

Example usage: Create a script called "Effectiveness Example", drag and drop it under the object bar effects, open the script, enter the following code to save, run the game, and you will see the effect of particle changes in the scene. The code is as follows:

ts
@Component
export default class EffectExample extends Script {

    protected onStart(): void {

         let Effect = this.gameObject as ParticleEmitter;
         // Involving modifications to the effects within the lifecycle
         // The effect of creating a size lifecycle array transitions from blue linear to red
         let ColorSequence = Array<mw.colorSequencePoint>();
         // When the lifecycle is 0%, it is blue. See LinearColor for details
         ColorSequence.push(new mw.colorSequencePoint(0, new LinearColor(1,0,0)));
         // Red at 100% lifecycle
         ColorSequence.push(new mw.colorSequencePoint(0, new LinearColor(0,0,1)));
         Effect.color = ColorSequence;
         // Create transparency life cycle array with gradually clear effect
         let TransparencySequence = Array<mw.numberSequencePoint>();
         // The transparency is 0 when it is just generate, and it cannot be seen
         TransparencySequence.push(new mw.numberSequencePoint(0, 0));
         // Gradually transitioning to full display at the end of the lifecycle
         TransparencySequence.push(new mw.numberSequencePoint(1, 1));
         Effect.transparency = TransparencySequence;

         // Create size life cycle array effect to become larger and then smaller
         let SizeSequence = Array<mw.numberSequencePoint>();
         // When the lifecycle is 0%, the size is 0
         Size
         // At 50% of the lifecycle, the size is 4
         SizeSequence.push(new mw.numberSequencePoint(0.5, 4));
         // When the lifecycle reaches 100%, the size returns to 0
         SizeSequence.push(new mw.numberSequencePoint(1, 0));
         Effect.size = SizeSequence;

         // Set the special effect resistance to 1
         Effect.drag = 1;
         // Increase the speed of effect generate
         Effect.rate = 100;
         // No edge cull, keep all, square
         Effect.maskRadius = 1;
         // Generate in spherical range
         Effect.shape = mw.ParticleEmitterShape.Sphere;
         // Generate only on spherical surface
         Effect.shapeStyle = mw.ParticleEmitterShapeStyle.OnlySurface;

         // The lifecycle is randomly within the range of 1-10
         Effect.lifetime = new Vector2(1, 10);
         // Stop after 10 seconds without affecting the generate particle
         setTimeout(() => {
             Effect.stop();
         }, 10000);
    }
}
@Component
export default class EffectExample extends Script {

    protected onStart(): void {

         let Effect = this.gameObject as ParticleEmitter;
         // Involving modifications to the effects within the lifecycle
         // The effect of creating a size lifecycle array transitions from blue linear to red
         let ColorSequence = Array<mw.colorSequencePoint>();
         // When the lifecycle is 0%, it is blue. See LinearColor for details
         ColorSequence.push(new mw.colorSequencePoint(0, new LinearColor(1,0,0)));
         // Red at 100% lifecycle
         ColorSequence.push(new mw.colorSequencePoint(0, new LinearColor(0,0,1)));
         Effect.color = ColorSequence;
         // Create transparency life cycle array with gradually clear effect
         let TransparencySequence = Array<mw.numberSequencePoint>();
         // The transparency is 0 when it is just generate, and it cannot be seen
         TransparencySequence.push(new mw.numberSequencePoint(0, 0));
         // Gradually transitioning to full display at the end of the lifecycle
         TransparencySequence.push(new mw.numberSequencePoint(1, 1));
         Effect.transparency = TransparencySequence;

         // Create size life cycle array effect to become larger and then smaller
         let SizeSequence = Array<mw.numberSequencePoint>();
         // When the lifecycle is 0%, the size is 0
         Size
         // At 50% of the lifecycle, the size is 4
         SizeSequence.push(new mw.numberSequencePoint(0.5, 4));
         // When the lifecycle reaches 100%, the size returns to 0
         SizeSequence.push(new mw.numberSequencePoint(1, 0));
         Effect.size = SizeSequence;

         // Set the special effect resistance to 1
         Effect.drag = 1;
         // Increase the speed of effect generate
         Effect.rate = 100;
         // No edge cull, keep all, square
         Effect.maskRadius = 1;
         // Generate in spherical range
         Effect.shape = mw.ParticleEmitterShape.Sphere;
         // Generate only on spherical surface
         Effect.shapeStyle = mw.ParticleEmitterShapeStyle.OnlySurface;

         // The lifecycle is randomly within the range of 1-10
         Effect.lifetime = new Vector2(1, 10);
         // Stop after 10 seconds without affecting the generate particle
         setTimeout(() => {
             Effect.stop();
         }, 10000);
    }
}

Hierarchy

Table of contents

Properties

click

Properties

onBeforeDestroyDelegate: MulticastDelegate<() => void> other
Event callback before object destruction
onCustomPropertyChange: Readonly<MulticastDelegate<(path: string, value: unknown, oldValue: unknown) => void>> other
Monitor custom attribute synchronization events
onDestroyDelegate: MulticastDelegate<() => void> other
Event callback after object destruction
onPropertyChange: Readonly<MulticastDelegate<(path: string, value: unknown, oldValue: unknown) => void>>
Monitor system replicated events

Accessors

acceleration(): vectorSequencePoint[] other
Obtain the acceleration change curve within the lifecycle
brightness(): number other
Brightness
color(): [color](mw.ParticleEmitter.md#color)SequencePoint[] other
Obtain the color change curve within the set lifecycle
drag(): number other
resistance
lifetime(): Vector2 other
life cycle
lightInfluence(): number other
Light influence
maskRadius(): number other
mask radius
rate(): number other
Rate (i.e. the number of particles generated per unit time)
rotSpeed(): numberSequencePoint[] other
Obtain the rotation speed change curve within the lifecycle
rotation(): number other
Initial rotation
shapeExtents(): Vector other
Shape range
shapeStyle(): ParticleEmitterShapeStyle other
Shape style
size(): numberSequencePoint[] other
Obtain the size change curve within the lifecycle
speed(): Vector2 other
Initial speed
spreadAngle(): number other
Diffusion angle
texture([texture](mw.ParticleEmitter.md#texture)Id): void other
Custom texture
transparency(): numberSequencePoint[] other
Obtain the transparency change curve within the lifecycle
click

Accessors

actorFlagValue(): number other
Get object tags
actorLevel(): number other
Obtain Actor Level
assetId(): string other
Retrieve the UID of the resource currently being used by the object
gameObjectId(): string other
Get the unique identification of an object (a string that uniquely identifies an object).
isDestroyed(): boolean other
Has the current object been destroyed
isReady(): boolean other
Current object status
localTransform(): Transform other
Local transformation of the current object
name(): string other
Return the current object name
netStatus(): NetStatus other
Get the current object synchronization status
parent(): GameObject other
Retrieve the current parent object
tag(): string other
Get the tag of the current object
worldTransform(): Transform other
Current object world transformation

Methods

forceStop(): void other
Force effect to stop, and destroy all particle
play(): void other
Play effect
stop(): void other
Stop effect without affecting generate particle
click

Methods

addComponent<T: extends Script<T>>(constructor: (...args: unknown[]) => T: extends Script<T>, bInReplicates?: boolean): T: extends Script<T> other
Add a script component
asyncGetChildByName(name: string): Promise<GameObject> other
Asynchronous search for sub objects based on their names
asyncReady(): Promise<GameObject> other
Return after the object is ready
clone(gameObjectInfo?: GameObjectInfo): GameObject other
Copy Objects
destroy(): void other
delete object
getBoundingBox(nonColliding?: boolean, includeFromChild?: boolean, outer?: Vector): Vector other
Get the size of the object's bounding box
getBounds(onlyCollidingComponents: boolean, originOuter: Vector, boxExtentOuter: Vector, includeFromChild?: boolean): void other
Obtain object boundaries
getChildByGameObjectId(gameObjectId: string): GameObject other
Search for sub objects based on gameObjectid
getChildByName(name: string): GameObject other
Search for sub objects by name
getChildByPath(path: string): GameObject other
Find sub objects according to path
getChildren(): GameObject[] other
Obtain sub objects
getChildrenBoundingBoxCenter(outer?: Vector): Vector other
Get the center point of all child objects' bounding box (not including the parent object, if the parent object is unavailable, return [0,0,0])
getChildrenByName(name: string): GameObject[] other
Search for all sub objects by name
getComponent<T: extends Script<T>>(constructor?: (...args: unknown[]) => T: extends Script<T>): T: extends Script<T> other
Get the component of the specified type
getComponentPropertys<T: extends Script<T>>(constructor: (...args: unknown[]) => T: extends Script<T>): Map<string, IPropertyOptions> other
Get property of script component
getComponents<T: extends Script<T>>(constructor?: (...args: unknown[]) => T: extends Script<T>): T: extends Script<T>[] other
Get all component of the specified type
getCustomProperties(): string[] other
Get all customize property
getCustomProperty<T: extends CustomPropertyType>(propertyName: string): T: extends CustomPropertyType other
Get customize property
getCustomPropertyChangeDelegate(property): Readonly<MulticastDelegate<(path: string, value: unknown, oldValue: unknown) => void>> other
Event proxy triggered when a given object property is modified
getPropertyChangeDelegate(property): Readonly<MulticastDelegate<(path: string, value: unknown, oldValue: unknown) => void>> other
Event proxy triggered when a given object property is modified
getVisibility(): boolean other
Obtain whether the object is displayed
isPrefabActor(): boolean other
Return whether the current object is a prefabricated body
moveBy(velocity: Vector, isLocal?: boolean): void other
Smoothly move an object over time according to a given velocity vector
moveTo(targetPosition: Vector, time: number, isLocal?: boolean, onComplete?: () => void): void other
Smoothly move from the current position to the target position within the specified time
rotateBy(rotation: Quaternion Rotation, multiplier: number, isLocal?: boolean): void other
Rotate the object smoothly over time according to the given rotation amount
rotateTo(targetRotation: Quaternion Rotation, time: number, isLocal?: boolean, onComplete?: () => void): void other
Smoothly changes from the current rotation to the target rotation within the specified time
scaleBy(scale: Vector, isLocal?: boolean): void other
Smoothly scale objects over time using a given scaling vector per second
scaleTo(targetScale: Vector, time: number, isLocal?: boolean, onComplete?: () => void): void other
Smoothly changes from the current scale to the target scale within the specified time
setAbsolute(absolutePosition?: boolean, absoluteRotation?: boolean, absoluteScale?: boolean): void other
Set whether the object localTransform is relative to the parent object or the world
setCustomProperty(propertyName: string, value: undefined CustomPropertyType): void other
Set custom attributes
setVisibility(status: boolean PropertyStatus, propagateToChildren?: boolean): void other
Set whether the object is displayed
stopMove(): void other
Interrupt further movement of moveTo() and moveBy()
stopRotate(): void other
Interrupt further rotation from rotateTo() or rotateBy()
stopScale(): void other
Interrupt further scale from ScaleTo() or ScaleBy()
asyncFindGameObjectById(gameObjectId: string): Promise<GameObject> other
Asynchronous search for GameObject through gameObjectid
asyncGetGameObjectByPath(path: string): Promise<GameObject> other
Asynchronously find objects through path
asyncSpawn<T: extends GameObject<T>>(assetId: string, gameObjectInfo?: GameObjectInfo): Promise<T: extends GameObject<T>> other
Asynchronous construction of an object
bulkPivotTo(gameObjects: GameObject[], transforms: Transform[]): void other
Batch set position
findGameObjectById(gameObjectId: string): GameObject other
Search for objects through gameObjectid
findGameObjectByName(name: string): GameObject other
Search for objects by name
findGameObjectsByName(name: string): GameObject[] other
Search for objects by name
findGameObjectsByTag(tag: string): GameObject[] other
Get objects through customize tag
getGameObjectByPath(path: string): GameObject other
Search for objects through paths
spawn<T: extends GameObject<T>>(assetId: string, gameObjectInfo?: GameObjectInfo): T: extends GameObject<T> other
Construct an object

Properties

Accessors

acceleration

get acceleration(): vectorSequencePoint[] other

set acceleration(sequence): void other

Obtain the acceleration change curve within the lifecycle

Returns

vectorSequencePoint[]Special effects vector value curve node array

Set the acceleration change curve within the lifecycle

Parameters

sequence vectorSequencePoint[]Usage: effect vector value curve node array

brightness

get brightness(): number other

set brightness(brightness): void other

Brightness

Returns

numberBrightness of effect

Brightness

Parameters

brightness numberUsage: Generate brightness of particles

color

get color(): colorSequencePoint[] other

set color(sequence): void other

Obtain the color change curve within the set lifecycle

Returns

colorSequencePoint[]Node array of effect color value curve

Set the color change curve within the lifecycle

Parameters

sequence colorSequencePoint[]Usage: special effect color value curve node array

drag

get drag(): number other

set drag(drag): void other

resistance

Returns

numberResistance of special effects

resistance

Parameters

drag numberUsage: resistance to generate particle

lifetime

get lifetime(): Vector2 other

set lifetime(lifetime): void other

life cycle

Returns

Vector2The lifecycle of special effects (x is the minimum value and y is the maximum value, randomly selected within the range of x~y during particle generation)

life cycle

Parameters

lifetime Vector2Usage: life cycle, the existence time of particle (x is the minimum value, y is the maximum value, and particle are randomly selected in the range of x~y when generate)

lightInfluence

get lightInfluence(): number other

set lightInfluence(lightInfluence): void other

Light influence

Returns

numberThe degree of lighting influence on special effects

Light influence

Parameters

lightInfluence numberUsage: lighting influence degree of effect

maskRadius

get maskRadius(): number other

set maskRadius(radius): void other

mask radius

Returns

numberMask culling radius for generate particle

mask radius

Parameters

radius numberUsage: mask culling radius of generate particle

rate

get rate(): number other

set rate(rate): void other

Rate (i.e. the number of particles generated per unit time)

Returns

numberRate of effect

Rate (i.e. the number of particles generated per unit time)

Parameters

rate numberUsage: speed

rotSpeed

get rotSpeed(): numberSequencePoint[] other

set rotSpeed(sequence): void other

Obtain the rotation speed change curve within the lifecycle

Returns

numberSequencePoint[]Special effects scalar value curve node array

Set the rotation speed variation curve within the lifecycle

Parameters

sequence numberSequencePoint[]Usage: effect scalar value curve node array

rotation

get rotation(): number other

set rotation(initialRotation): void other

Initial rotation

Returns

numberInitial rotation of special effects

Initial rotation

Parameters

initialRotation numberUsage: Generate initial rotation value for particles

shapeExtents

get shapeExtents(): Vector other

set shapeExtents(extents): void other

Shape range

Returns

VectorShape style of effect

Shape range

Parameters

extents VectorUsage: The shape range of the special effect (sets the size of the particle emitter shape, which determines how wide the particles will be randomly generated) Effective only for non dot types X Represent the side length of circle/sphere radius triangle Y Representing the interior angles of isosceles triangles Z Representing volume height

shapeStyle

get shapeStyle(): ParticleEmitterShapeStyle other

set shapeStyle(style): void other

Shape style

Returns

ParticleEmitterShapeStyleShape style of effect

Shape style

Parameters

style ParticleEmitterShapeStyleUsage: effect shape style surface generate or generate within volume, only effective when it is not a point type)

size

get size(): numberSequencePoint[] other

set size(sequence): void other

Obtain the size change curve within the lifecycle

Returns

numberSequencePoint[]

Set the size change curve within the lifecycle

Parameters

sequence numberSequencePoint[]Usage: effect scalar value curve node array

speed

get speed(): Vector2 other

set speed(speed): void other

Initial speed

Returns

Vector2Initial velocity of generate particle (x is the minimum value and y is the maximum value, and particle are randomly selected in the range of x~y when generate)

Initial speed

Parameters

speed Vector2Usage: initial velocity of generate particle (x is the minimum value, y is the maximum value, and particle are randomly selected in the range of x~y when generate)

spreadAngle

get spreadAngle(): number other

set spreadAngle(spreadAngle): void other

Diffusion angle

Returns

numberDiffusion angle of effect

Diffusion angle

Parameters

spreadAngle numberUsage: Generate the diffusion angle of particles

texture

set texture(textureId): void other

Custom texture

Parameters

textureId string numberUsage: Custom texture ID for special effects

transparency

get transparency(): numberSequencePoint[] other

set transparency(sequence): void other

Obtain the transparency change curve within the lifecycle

Returns

numberSequencePoint[]Special effects scalar value curve node array

Set transparency change curve within the lifecycle

Parameters

sequence numberSequencePoint[]Usage: effect scalar value curve node array

Methods


forceStop

forceStop(): void other

Force effect to stop, and destroy all particle


play

play(): void other

Play effect


stop

stop(): void other

Stop effect without affecting generate particle