Particles not visible

Hello,

I want to add Snow-Particles on top of my scene.
In Particle-Editor preview, they show up fine, but when I run the game nothing shows up at all.

First some pictures:
This is how it looks in Particle-Editor preview:

These are the Emitter Settings:


(Additionally: Position 0, 0, 1; Rotation 0, 0, 0; everything under “Particle” is set to 1 except Life Alpha (readonly) and Life Rotation are set to 0)

This is how the main.collection is set up (moved the particles a bit to the right because I thought they don’t show up because they are rendered behind the map (which is not the case)):

Inside the script next to particlefx I wrote:

function init(self)
    particlefx.play("#particlefx", testpfx)
    print("OK")
end

function testpfx(self, id, emitter, state)
    -- 3 print(particlefx.EMITTER_STATE_POSTSPAWN)
    -- 1 print(particlefx.EMITTER_STATE_PRESPAWN)
    -- 0 print(particlefx.EMITTER_STATE_SLEEPING)
    -- 2 print(particlefx.EMITTER_STATE_SPAWNING)
    print("particle state: "..state)
end

function final(self)
    particlefx.stop("#particlefx")
end

The console output looks like this:

INFO:ENGINE: Defold Engine 1.2.102 (d530758)
INFO:ENGINE: Loading data from: build/default
INFO:ENGINE: Initialised sound device ‘default’

DEBUG:SCRIPT: OK
DEBUG:SCRIPT: particle state: 1
INFO:DLIB: SSDP: Started on address 192.168.2.128
DEBUG:SCRIPT: particle state: 2
INFO:DLIB: SSDP: Done on address 192.168.2.128

So it seems like they are spawning (particle state 2 == particlefx.EMITTER_STATE_SPAWNING) but they don’t show up.
Can someone please shove me in the right direction, please? :slight_smile:

~ Daniel

Have you changed the Z positions of the component or its parent game object? The default render script only shows things between -1 and 1.

Just checked to make sure:
emitter is set to 1
particlefx is set to 1
particles (gameobject) is set to 1
level (collection) is set to 0
script is set to 0

I zipped the project if that helps:
project.zip (2.2 MB)

Remember that these will add up to a final z-value of 3, not 1 as you seem to expect. A component such as a sprite or particle fx will inherit the z-value of the game object they are attached to. The same will happen when you have a hierarchy of game objects.

2 Likes

Yup, that was it. Set them all to zero and it shows up.

In the default render script, all particles are rendered after sprites and tile maps, so you don’t have to worry about the snow being on top.

2 Likes

They add up? I totally wasn’t aware of that. Thank you both!
I guess, that would have caused some further errors down the road, but now - thanks to you - I know how to avoid that :slight_smile:
Thanks again :slight_smile:

If you have something that is the child of another thing, its position is relative to its parent. So all component positions are relative to (i.e. added to) their parent game object’s position.

The same goes for rotation and scale. You can get really messed up if you scale things and forget later, especially with non-uniform scaling.

2 Likes

Ah, that’s how it works. Thanks for the clarification! That actually helps a lot :slight_smile:

So far I am really liking the Defold Engine. The only thing that messes my brain up a bit is that XY 0,0 is in the bottom left corner instead of the top left, but I’ll get used to it eventually (at least I hope so :sweat_smile:)

2 Likes

I guess this depends on which game engines or frameworks you’ve used in the past. I believe Unity also has a bottom-left coordinate system.

It’s helpful to remember that Defold is a 3d engine. Or think of it like it is a math graph. The way it does the positioning is much better than starting at the top left and making y increase in value as it goes downward like some engines do…


4 Likes