Examples
Examples

Particle Effect Emission Space


Setup

This example shows how particle emission space affects particle behavior when the emitter object moves. The setup consists of two UFO objects with identical particle effects, but different emission space settings.

Setup

The example collection consists of 2 game objects that differ only in the particlefx used:

  • particlefx on the left has Emission Space property set to Emitter:

Emission Space: Emitter

  • particlefx on the right has Emission Space property set to World:

Emission Space: World

Both game objects are animated up and down, so that you can see the difference between the emission space:

Screenshot showing particle emission space comparison

How it works?

Particles emitted in the emitter space are “moving” with the object, so their position is always respective to the emitter actual origin.

Particles emitted in the world space have positions respective to the world coordinates.

Use this example to understand when to use local or world emission space in your particle effects!

Scripts

particlefx.script

function init(self)
    particlefx.play("#particles") -- <1>
    go.animate(".", "position.y", go.PLAYBACK_LOOP_PINGPONG, 500, go.EASING_INOUTSINE, 4) -- <2>
end

--[[
1. Start playing the particle effect in component "particles" in this game object.
2. Animate this object position on Y axis up and down forever
]]

This example was created by Defold Foundation.

Download ⤓

 

Do you want to see more examples? Why not write a few yourself and submit a pull request? We love contributions.

Add example ↗