Particles Module
Tiny supports a subset of the particle workflows available in Unity. This subset is referred to as the Particles module. This document provides common use cases, examples, and a reference of Particles components.
See this module's API documentation for more information
Use Cases and Examples
This section demonstrates how to use the Particles module through common use cases and usage examples. If a use case or an example is similar to a topic in the Unity User Manual, a link is provided to the appropriate topic.
Simple Particle System
- Create a Sprite2D entity. This will be your proto-particle.
- Create an entity.
- Add a ParticleEmitter component.
- Set the
particle
property to the Sprite2D entity. - Add a EmitterBoxSource component.
Modify the ParticleEmitter or the EmitterBoxSource properties to affect the emission (e.g. emission rate).
Spawn particles with initial modifiers
After adding a particle system, it is easy to control the state of newly created particles. From the ParticleEmitter component, you can add a related component using the +
button.
- Add a EmitterInitialScale component to set the scale of each particle on emission.
- Add a EmitterInitialRotation component to set the rotation around the z-axis of each particle on emission.
- Add a EmitterInitialVelocity component to set the velocity (direction and speed) of each particle on emission.
For each of these components, it is possible to define the upper and lower bounds for the value; the actual value varies randomly between those bounds.
Spawn particles with changes over time
After adding a particle system, it is easy to specify the particle's changes over time. From the ParticleEmitter component, you can add a related component using the +
button. Using a change over time component will most likely override any initial value component you provided.
Changing the color and alpha over time.
- Create an empty entity and name it ColorOverTimeKeys.
- Add a component KeyColor. The component holds the list of Color keyframes for the interpolation.
- Add two keys and set time 0.0 for the first one and 1.0 for the second one. Set different color/alpha values for both keys.
- Create an empty entity and name it ColorOverTimeCurve.
- Add a component LinearCurveColor.
- Drag and drop entity ColorOverTimeKeys into
keys
field.
- Select an emitter entity.
- Add a LifetimeColor component to the particle system entity in order to change the particle's color over time.
- Drag and drop ColorOverTimeCurve entity to
curve
field in LifetimeColor component.
Changing the speed over time.
- Create an empty entity and name it SpeedMultiplierOverTimeKeys.
- Add a component KeyFloat. The component holds the list of Float keyframes for the interpolation.
- Add two keys and set time 0.0 for the first one and 1.0 for the second one. Set
speed
to 5.0 for the first key and leave 0.0 fot the second.
- Create an empty entity and name it SpeedMultiplierOverTimeCurve.
- Add a component LinearCurveFloat.
- Drag and drop entity SpeedMultiplierOverTimeKeys into
keys
field.
- Select an emitter entity.
- Add a LifetimeSpeedMultiplier component to the particle system entity in order to change the particle's speed over time.
- Drag and drop SpeedMultiplierOverTimeCurve entity to
curve
field in LifetimeSpeedMultiplier component.
Components
Tiny is built around small, lightweight components. This way you only pay for what you need. This design usually creates more component types to represent data held in a single Unity component, which can be confusing at first for some developers.
Use this table to associate familiar Unity concepts with Tiny.
Unity Particle System Module | Particles Components |
---|---|
Emission, Shape | EmitterBoxSource, EmitterCircleSource, EmitterConeSource |
Color Over Lifetime | LifetimeColor |
Rotation Over Lifetime | LifetimeAngularVelocity |
Size Over Lifetime | LifetimeScale |
Velocity Over Lifetime | LifetimeVelocity, LifetimeSpeedMultiplier |
Particle System Main module | ParticleEmitter |
Unity Particle System Property | Particles Components |
---|---|
3D Start Rotation, Start Rotation | EmitterInitialRotation, [EmitterInitialAngularVelocity][#emitterinitialangularvelocity] |
Start Size | EmitterInitialScale |
Start Speed | EmitterInitialVelocity |
EmitterBoxSource
- Requires: ParticleEmitter
- Unity References: Emission module, Shape module
Change the Shape of emission to a Box with defined position and scale. Particles will be emitted from a random spot inside the box. The rect
will be centered around the emitter's position.
Defaults the emission Rate over Time (number of particles emitted per unit of time) to 10.
Property | Description |
---|---|
rect | The region of the entity to use as the box emitter source. The position is set with the x and y values. The scaling is set with the width and height. Defaults width and height to 50. |
attachToEmitter | Sets whether the emitted particle's transform will be a child of this emitter. If true, the emission position is set as the entity's local position, and the particle will be added as a transform child. If false, the emitter's world position will be added to the emission position, and that result is set as the local position. |
EmitterCircleSource
- Requires: ParticleEmitter
Change the Shape of emission to a Circle with defined radius and speed. Particles will be emitted from a random spot inside the circle with the random speed.
Property | Description |
---|---|
radius | Radius of the emitter |
speed | Initial speed of the particles. |
speedBasedOnRadius | If true, the initial speed is based on the initial particle's distance from the center of the emitter. |
EmitterConeSource
- Requires: ParticleEmitter
Change the Shape of emission to a cone with defined radius, angle, and speed. Particles will be emitted from a random spot inside the base of the cone with the random speed and angle.
Property | Description |
---|---|
radius | The radius of the base of the cone |
angle | The angle of the cone |
speed | Initial speed of the particles. |
EmitterInitialRotation
- Requires: ParticleEmitter
- Unity Reference: Particle System Main module
Sets the initial angle of each particle on emission.
Since the particle system is only in 2D coordinates as of right now, the angle is around the z-axis.
Property | Description |
---|---|
angle | The initial rotation angle in degrees of each particle around the z-axis. If the start and end values are the same, the initial rotation is constant. Otherwise, the rotation is a random value between the start and end values. |
EmitterInitialScale
- Requires: ParticleEmitter
- Unity Reference: Particle System Main module
Sets the initial scale of each particle on emission.
Property | Description |
---|---|
scale | The initial scale of each particle. Defaults to 1. If the start and end values are the same, the initial scale is constant. Otherwise, the scale is a random value between the start and end values. |
EmitterInitialVelocity
- Requires: ParticleEmitter
- Unity Reference: Particle System Main module
Sets the initial velocity of each particle on emission. The length of the velocity vector stands for the initial speed of the particle.
Property | Description |
---|---|
velocity | The initial emission velocity of each particle from the chosen emission position. |
LifetimeColor
- Requires: ParticleEmitter
- Unity Reference: Color Over Lifetime module
Specifies how a particle's color changes over its lifetime. It modifies the Sprite2DRenderer's color.
Property | Description |
---|---|
curve | A curve which defines the particle's color over its lifetime. In this case, the curve is a visual representation of a colour progression, which simply shows the main colours (which are called stops) and all the intermediate shades between them. |
LifetimeAngularVelocity
Requires: ParticleEmitter
Specifies how a particle's angular velocity changes over its lifetime. It modifies the Transform's local rotation.
This component uses angular velocity in the editor and explicit rotation values in the runtime. In Unity, the rotation over lifetime indicates an angular velocity in degrees per second whereas in Tiny, the LifetimeRotation indicates the actual rotation value used at time x.
Property | Description |
---|---|
curve | A curve which defines the particle's angular velocity in degrees around the z-axis over its lifetime. In this case, the curve is a line graph that sets the angular velocity over time. |
LifetimeScale
- Requires: ParticleEmitter
- Unity Reference: Size Over Lifetime module
Specifies how a particle's scale changes over its lifetime. It modifies the Transform's scale with a uniform scale (on x, y, z axis).
Property | Description |
---|---|
curve | A curve which defines how the particle's scale changes over its lifetime. In this case, the curve is a line graph that sets the scale over time. |
LifetimeVelocity
- Requires: ParticleEmitter
- Unity Reference: Velocity Over Lifetime module
Specifies how a particle's velocity (direction and speed) changes over its lifetime.
Property | Description |
---|---|
curve | A curve which defines how the particle's velocity changes over its lifetime. The net velocity used for modyfying the particle's position is calculated by adding the initial velocity and the velocity over time. |
BurstEmission
- Requires: ParticleEmitter
An emitter with this component emits particles in bursts. A burst is a particle event where a number of particles are all emitted at the same time. A cycle is a single occurrence of a burst.
Property | Description |
---|---|
count | How many particles in every cycle. |
interval | The interval between cycles, in seconds. |
cycles | How many times to play the burst |
ParticleEmitter
- Requires: UTiny.Core2D, UTiny.Math
- Unity References: Graphics.Particle Systems, Particle System Main module
This is the core particle emitter component. When added to an entity, it becomes an emitter with given characteristics. The system continuously emits particles (loop). It is linked to the source data, the initial values and the lifetime values for particles. It contains global properties that affect the whole system (e.g. lifetime
property). Various particle modifiers after initial emit can be added as component (e.g. EmitterInitialScale).
The Unity
Prewarm
's property is enabled if the prewarmPercent is equal or more than 0.5.
Property | Description |
---|---|
particle | The UTiny entity attached to the particle system and rendered in run-time. This proto-particle is used as a template. |
maxParticles | The maximum number of particles in the system at once. If the limit is reached, some particles are removed. Defaults to 1000. |
emitRate | The number of particles emitted per second. Defaults to 10. |
lifetime | The lifetime of each particle in seconds. Defaults start (min) and end (max) to 5. |
attachToEmitter | If true, then newly spawned particles will be children of the emitter. |
Systems
ParticleSystem
- Updates Before: Shared.InputFence, Shared.RenderingFence
The main entry system for particles. Spawns particles with given initial characteristics and updates particles' properties (scale, color, alpha, rotation) over time.