Skip to content

Commit d7e3b9f

Browse files
authored
Added example for particlefx emission space difference. (#128)
1 parent 4cd0b58 commit d7e3b9f

File tree

15 files changed

+462
-0
lines changed

15 files changed

+462
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
path_settings {
2+
path: "**"
3+
profile: "Default"
4+
}
5+
profiles {
6+
name: "Default"
7+
platforms {
8+
os: OS_ID_GENERIC
9+
formats {
10+
format: TEXTURE_FORMAT_RGBA
11+
compression_level: BEST
12+
compression_type: COMPRESSION_TYPE_DEFAULT
13+
}
14+
mipmaps: false
15+
max_texture_size: 0
16+
premultiply_alpha: true
17+
}
18+
}
Binary file not shown.
906 Bytes
Loading
2.3 KB
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
images {
2+
image: "/assets/images/spaceEffects_016.png"
3+
}
4+
images {
5+
image: "/assets/images/ufoGreen.png"
6+
}
7+
extrude_borders: 2
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
font: "/assets/SourceSansPro-Semibold.ttf"
2+
material: "/builtins/fonts/font.material"
3+
size: 48
4+
outline_alpha: 0.0
5+
outline_width: 0.0
3.16 KB
Loading
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
tags: particles
3+
title: Particle Effect Emission Space
4+
brief: This example demonstrates the difference between local and world particle emission spaces. Two UFO objects move up and down, showing how particles behave differently when emitted in emitter space versus world space.
5+
author: Defold Foundation
6+
scripts: particlefx.script
7+
thumbnail: thumbnail.png
8+
---
9+
10+
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.
11+
12+
The example collection consists of 2 game objects that differ only in the particlefx used:
13+
14+
- particlefx on the left has Emission Space property set to "Emitter":
15+
![Emission Space: Emitter](emitter.png)
16+
17+
- particlefx on the right has Emission Space property set to "World":
18+
![Emission Space: World](world.png)
19+
20+
Both game objects are animated up and down, so that you can see the difference between the emission space:
21+
22+
![Screenshot showing particle emission space comparison](thumbnail.png)
23+
24+
Particles emitted in emitter space are "moving" with the object, so their position is always respective to the emitter actual origin.
25+
26+
Particles emitted in world space have positions respective to the world coordinates.
27+
28+
Use this example to understand when to use local vs world emission space in your particle effects!
29+
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
emitters {
2+
mode: PLAY_MODE_LOOP
3+
duration: 1.0
4+
space: EMISSION_SPACE_EMITTER
5+
tile_source: "/assets/sprites.atlas"
6+
animation: "spaceEffects_016"
7+
material: "/builtins/materials/particlefx.material"
8+
max_particle_count: 512
9+
type: EMITTER_TYPE_CIRCLE
10+
properties {
11+
key: EMITTER_KEY_SPAWN_RATE
12+
points {
13+
y: 20.0
14+
}
15+
}
16+
properties {
17+
key: EMITTER_KEY_SIZE_X
18+
points {
19+
y: 8.0
20+
}
21+
}
22+
properties {
23+
key: EMITTER_KEY_SIZE_Y
24+
points {
25+
y: 12.0
26+
}
27+
}
28+
properties {
29+
key: EMITTER_KEY_PARTICLE_LIFE_TIME
30+
points {
31+
y: 1.5
32+
}
33+
}
34+
properties {
35+
key: EMITTER_KEY_PARTICLE_SPEED
36+
points {
37+
y: 15.0
38+
}
39+
spread: 10.0
40+
}
41+
properties {
42+
key: EMITTER_KEY_PARTICLE_SIZE
43+
points {
44+
y: 20.0
45+
}
46+
}
47+
properties {
48+
key: EMITTER_KEY_PARTICLE_RED
49+
points {
50+
y: 1.0
51+
}
52+
}
53+
properties {
54+
key: EMITTER_KEY_PARTICLE_GREEN
55+
points {
56+
y: 1.0
57+
}
58+
}
59+
properties {
60+
key: EMITTER_KEY_PARTICLE_BLUE
61+
points {
62+
y: 1.0
63+
}
64+
}
65+
properties {
66+
key: EMITTER_KEY_PARTICLE_ALPHA
67+
points {
68+
y: 1.0
69+
}
70+
}
71+
particle_properties {
72+
key: PARTICLE_KEY_SCALE
73+
points {
74+
y: 1.0
75+
}
76+
}
77+
particle_properties {
78+
key: PARTICLE_KEY_RED
79+
points {
80+
y: 1.0
81+
}
82+
}
83+
particle_properties {
84+
key: PARTICLE_KEY_GREEN
85+
points {
86+
y: 1.0
87+
}
88+
}
89+
particle_properties {
90+
key: PARTICLE_KEY_BLUE
91+
points {
92+
y: 1.0
93+
}
94+
}
95+
particle_properties {
96+
key: PARTICLE_KEY_ALPHA
97+
points {
98+
y: 0.0
99+
t_x: 0.07194582
100+
t_y: 0.99740857
101+
}
102+
points {
103+
x: 0.11320755
104+
y: 0.99277455
105+
t_x: 0.99418455
106+
t_y: 0.10768964
107+
}
108+
points {
109+
x: 0.7112546
110+
y: 0.555656
111+
t_x: 0.5694311
112+
t_y: -0.82203907
113+
}
114+
points {
115+
x: 1.0
116+
y: 0.0072254334
117+
t_x: 0.4737472
118+
t_y: -0.8806609
119+
}
120+
}
121+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: "default"
2+
scale_along_z: 0
3+
embedded_instances {
4+
id: "world_emission_space"
5+
data: "components {\n"
6+
" id: \"script\"\n"
7+
" component: \"/example/particlefx.script\"\n"
8+
"}\n"
9+
"components {\n"
10+
" id: \"particles\"\n"
11+
" component: \"/example/world_emission_pfx.particlefx\"\n"
12+
"}\n"
13+
"embedded_components {\n"
14+
" id: \"sprite\"\n"
15+
" type: \"sprite\"\n"
16+
" data: \"default_animation: \\\"ufoGreen\\\"\\n"
17+
"material: \\\"/builtins/materials/sprite.material\\\"\\n"
18+
"size {\\n"
19+
" x: 91.0\\n"
20+
" y: 91.0\\n"
21+
"}\\n"
22+
"textures {\\n"
23+
" sampler: \\\"texture_sampler\\\"\\n"
24+
" texture: \\\"/assets/sprites.atlas\\\"\\n"
25+
"}\\n"
26+
"\"\n"
27+
"}\n"
28+
""
29+
position {
30+
x: 500.0
31+
y: 100.0
32+
}
33+
}
34+
embedded_instances {
35+
id: "local_emission_space"
36+
data: "components {\n"
37+
" id: \"particles\"\n"
38+
" component: \"/example/local_emission_pfx.particlefx\"\n"
39+
"}\n"
40+
"components {\n"
41+
" id: \"script\"\n"
42+
" component: \"/example/particlefx.script\"\n"
43+
"}\n"
44+
"embedded_components {\n"
45+
" id: \"sprite\"\n"
46+
" type: \"sprite\"\n"
47+
" data: \"default_animation: \\\"ufoGreen\\\"\\n"
48+
"material: \\\"/builtins/materials/sprite.material\\\"\\n"
49+
"textures {\\n"
50+
" sampler: \\\"texture_sampler\\\"\\n"
51+
" texture: \\\"/assets/sprites.atlas\\\"\\n"
52+
"}\\n"
53+
"\"\n"
54+
"}\n"
55+
""
56+
position {
57+
x: 200.0
58+
y: 100.0
59+
}
60+
}
61+
embedded_instances {
62+
id: "description"
63+
data: "embedded_components {\n"
64+
" id: \"label\"\n"
65+
" type: \"label\"\n"
66+
" data: \"size {\\n"
67+
" x: 512.0\\n"
68+
" y: 32.0\\n"
69+
"}\\n"
70+
"color {\\n"
71+
" x: 0.0\\n"
72+
" y: 0.102\\n"
73+
" z: 0.502\\n"
74+
"}\\n"
75+
"text: \\\"Emitter: World:\\\"\\n"
76+
"font: \\\"/builtins/fonts/default.font\\\"\\n"
77+
"material: \\\"/builtins/fonts/label-df.material\\\"\\n"
78+
"\"\n"
79+
" position {\n"
80+
" x: 350.0\n"
81+
" y: 670.0\n"
82+
" }\n"
83+
" scale {\n"
84+
" x: 1.5\n"
85+
" y: 1.5\n"
86+
" }\n"
87+
"}\n"
88+
""
89+
}

0 commit comments

Comments
 (0)