particle_systems_2d.rst 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. .. _doc_particle_systems_2d:
  2. Particle Systems (2D)
  3. =====================
  4. Intro
  5. -----
  6. A simple (but flexible enough for most uses) particle system is
  7. provided. Particle systems are used to simulate complex physical effects
  8. such as sparks, fire, magic particles, smoke, mist, magic, etc.
  9. The idea is that a "particle" is emitted at a fixed interval and with a
  10. fixed lifetime. During its lifetime, every particle will have the same
  11. base behavior. What makes every particle different and provides a more
  12. organic look is the "randomness" associated to each parameter. In
  13. essence, creating a particle system means setting base physics
  14. parameters and then adding randomness to them.
  15. Particles2D
  16. ~~~~~~~~~~~
  17. Particle systems are added to the scene via the
  18. :ref:`Particles2D <class_Particles2D>`
  19. node. However, after creating that node you will notice that only a white dot was created,
  20. and that there is a warning icon next to your Particles2D node in the inspector. This
  21. is because the node needs a ParticlesMaterial to function.
  22. ParticlesMaterial
  23. ~~~~~~~~~~~~~~~~~
  24. To add a process material to your particles node, go to Process Material in
  25. your inspector panel. Click on the box next to material, and from the dropdown
  26. menu select New Particles Material.
  27. .. image:: img/particles_material.png
  28. Your Particles2D node should now be emitting
  29. white points downward.
  30. .. image:: img/particles1.png
  31. Texture
  32. ~~~~~~~
  33. A particle system uses a single texture (in the future this might be
  34. extended to animated textures via spritesheet). The texture is set via
  35. the relevant texture property:
  36. .. image:: img/particles2.png
  37. Time Parameters
  38. ---------------
  39. Lifetime
  40. ~~~~~~~~
  41. The time in seconds that every particle will stay alive. When lifetime
  42. ends, a new particle is created to replace it.
  43. Lifetime: 0.5
  44. .. image:: img/paranim14.gif
  45. Lifetime: 4.0
  46. .. image:: img/paranim15.gif
  47. One Shot
  48. ~~~~~~~~
  49. When enabled, a Particles2D node will emit all of its particles once
  50. and then never again.
  51. Preprocess
  52. ~~~~~~~~~~
  53. Particle systems begin with zero particles emitted, then start emitting.
  54. This can be an inconvenience when loading a scene and systems like
  55. a torch, mist, etc. begin emitting the moment you enter. Preprocess is
  56. used to let the system process a given number of seconds before it is
  57. actually drawn the first time.
  58. Speed Scale
  59. ~~~~~~~~~~~
  60. The speed scale has a default value of ``1``, and is used to adjust the
  61. speed of a particle system. Lowering the value will make the particles
  62. slower, increasing the value will make the particles much faster.
  63. Explosiveness
  64. ~~~~~~~~~~~~~
  65. If lifetime is ``1`` and there are ten particles, it means a particle
  66. will be emitted every 0.1 seconds. The explosiveness parameter changes
  67. this, and forces particles to be emitted all together. Ranges are:
  68. - 0: Emit particles at regular intervals (default value).
  69. - 1: Emit all particles simultaneously.
  70. Values in the middle are also allowed. This feature is useful for
  71. creating explosions or sudden bursts of particles:
  72. .. image:: img/paranim18.gif
  73. Randomness
  74. ~~~~~~~~~~
  75. All physics parameters can be randomized. Random values range from ``0`` to
  76. ``1``. The formula to randomize a parameter is:
  77. ::
  78. initial_value = param_value + param_value * randomness
  79. Fixed FPS
  80. ~~~~~~~~~
  81. This setting can be used to set the particle system to render at a fixed
  82. FPS. For instance, changing the value to ``2`` will make the particles render
  83. at 2 frames per second. Note this does not slow down the particle system itself.
  84. Fract Delta
  85. ~~~~~~~~~~~
  86. This can be used to turn Fract Delta on or off.
  87. Drawing Parameters
  88. ------------------
  89. Visibility Rect
  90. ~~~~~~~~~~~~~~~
  91. The ``W`` and ``H`` values control width and height of the visibility
  92. rectangle. The ``X`` and ``Y`` values control the position of the upper-left
  93. corner of the visibility rectangle relative to the particle emitter.
  94. Local Coords
  95. ~~~~~~~~~~~~
  96. By default this option is on, and it means that the space that particles
  97. are emitted to is relative to the node. If the node is moved, all
  98. particles are moved with it:
  99. .. image:: img/paranim20.gif
  100. If disabled, particles will emit to global space, meaning that if the
  101. node is moved, already emitted particles are not affected:
  102. .. image:: img/paranim21.gif
  103. Draw Order
  104. ~~~~~~~~~~
  105. This controls the order in which individual particles are drawn. ``Index``
  106. means particles are drawn according to their emission order (default).
  107. ``Lifetime`` means they are drawn in order of remaining lifetime.
  108. ParticlesMaterial settings
  109. --------------------------
  110. ..
  111. Commented out as not implemented in 3.x for now.
  112. Direction
  113. ~~~~~~~~~
  114. This is the base angle at which particles emit. Default is ``0`` (down):
  115. .. image:: img/paranim1.gif
  116. Changing it will change the emissor direction, but gravity will still
  117. affect them:
  118. .. image:: img/paranim2.gif
  119. This parameter is useful because, by rotating the node, gravity will
  120. also be rotated. Changing direction allows them to be separated.
  121. Spread
  122. ~~~~~~
  123. This parameter is the angle in degrees which will be randomly added in
  124. either direction to the base ``Direction``. A spread of ``180`` will emit
  125. in all directions (+/- 180).
  126. .. image:: img/paranim3.gif
  127. Gravity
  128. ~~~~~~~
  129. The gravity applied to every particle.
  130. .. image:: img/paranim7.gif
  131. Initial Velocity
  132. ~~~~~~~~~~~~~~~~
  133. Linear velocity is the speed at which particles will be emitted (in
  134. pixels/sec). Speed might later be modified by gravity or other
  135. accelerations (as described further below).
  136. .. image:: img/paranim4.gif
  137. Angular Velocity
  138. ~~~~~~~~~~~~~~~~
  139. Angular velocity is the initial angular velocity applied to particles.
  140. Spin Velocity
  141. ~~~~~~~~~~~~~
  142. Spin velocity is the speed at which particles turn around their center
  143. (in degrees/sec).
  144. .. image:: img/paranim5.gif
  145. Orbit Velocity
  146. ~~~~~~~~~~~~~~
  147. Orbit velocity is used to make particles turn around their center.
  148. .. image:: img/paranim6.gif
  149. Linear Acceleration
  150. ~~~~~~~~~~~~~~~~~~~
  151. The linear acceleration applied to each particle.
  152. Radial Acceleration
  153. ~~~~~~~~~~~~~~~~~~~
  154. If this acceleration is positive, particles are accelerated away from
  155. the center. If negative, they are absorbed towards it.
  156. .. image:: img/paranim8.gif
  157. Tangential Acceleration
  158. ~~~~~~~~~~~~~~~~~~~~~~~
  159. This acceleration will use the tangent vector to the center. Combining
  160. with radial acceleration can do nice effects.
  161. .. image:: img/paranim9.gif
  162. Damping
  163. ~~~~~~~
  164. Damping applies friction to the particles, forcing them to stop. It is
  165. especially useful for sparks or explosions, which usually begin with a
  166. high linear velocity and then stop as they fade.
  167. .. image:: img/paranim10.gif
  168. Angle
  169. ~~~~~
  170. Determines the initial angle of the particle (in degress). This parameter
  171. is mostly useful randomized.
  172. .. image:: img/paranim11.gif
  173. Scale
  174. ~~~~~
  175. Determines the initial scale of the particles.
  176. .. image:: img/paranim12.gif
  177. Color
  178. ~~~~~
  179. Used to change the color of the particles being emitted.
  180. Hue variation
  181. ~~~~~~~~~~~~~
  182. The variation value sets the initial hue variation applied to each
  183. particle. The Variation rand value controls the hue variation
  184. randomness ratio.