Using Particles
In this document, you will learn how to load and use Particle Systems in your applications.
How to create particle systems from Evergine Studio
To instantiate a Particle System in a Scene, simply drag the particle system asset from the Asset Details Panel into your Scene.
This will create a new entity in the Scene.
The newly created entity has a Transform3D component and two new components:
ParticlesComponent
This component loads the Particle System asset and manages its simulation and resources.
It has the following methods:
Property | Description |
---|---|
StartEmitting () | Starts the particle system emission if it was stopped |
StopEmitting () | Stops the particle system emission if it was already emitting |
Reset () | Resets all particles to their initial state |
And the following properties:
Property | Type | Description |
---|---|---|
ParticleSystem | ParticleSystem | Selects the particle system asset for this entity. |
Force CPU Particles | boolean | Forces the particle system to use CPU simulation, even if the platform supports GPU particles. (false by default) |
Emit Automatically | boolean | When true, starts emitting particles when the scene is loaded. If false, it will be idle until it is manually started. (true by default) |
Life Factor | float | Factor applied to the lifetime of the particles. A value of 2 will cause the particles' life to be reduced by half. (1 by default) |
Time Factor | float | Time factor applied to the whole particle simulation. A value of 2 will cause particles to move at double speed, while 0.5 will slow down particles to half speed. (1 by default) |
Load Particle System from code
The following sample code can be used to create a new Particle force entity in your scene.
protected override void CreateScene()
{
// Load Particle System
ParticleSystem particlesAsset = this.Managers.AssetSceneManager.Load<ParticleSystem>(EvergineContent.Particles.MyParticleSystem);
// Apply to an entity
Entity particlesEntity = new Entity()
.AddComponent(new Transform3D())
.AddComponent(new ParticlesComponent()
{
ParticleSystem = particlesAsset
})
.AddComponent(new ParticlesRenderer());
this.Managers.EntityManager.Add(particlesEntity);
}