Version: 2018.4
What is a Particle System?
Particle System How-Tos

Использование систем частиц в Unity

Unity implements Particle Systems with a component, so placing a Particle System in a Scene is a matter of adding a pre-made GameObject (menu: GameObject > Effects > Particle System) or adding the component to an existing GameObject (menu: Component > Effects > Particle System). Because the component is quite complicated, the Inspector is divided into a number of collapsible sub-sections or modules that each contain a group of related properties. Additionally, you can edit one or more systems at the same time using a separate Editor window accessed via the Open Window button in the Inspector. See documentation on the Particle System component and individual Particle System modules to learn more.

При выборе объекта с системой частиц, в окне Scene появится небольшая панель Particle Effect с простыми элементами управления для удобной визуализации изменений, вносимых в настройки системы.

Скорость проигрывания (поле Playback Speed) позволяет ускорить или замедлить симуляцию частиц, что позволяет быстро проверить как она будет работать в заданном режиме. Время проигрывания (поле Playback Time) показывает количество времени, прошедшего с начала симуляции; оно может не совпадать в реальным временем, если изменялась скорость проигрывания. Время проигрывание может быть “отмотано” назад и вперед с помощью зажатия левой клавиши мыши над надписью Playback Time с последующим перетаскиванием воображаемого ползунка влево и вправо. Кнопки в верхней части панели позволяют приостановить и продолжить выполнение симуляции, либо остановить её и сбросить в первоначальное состояние.

Изменение свойств с течением времени

Многие числовые свойства частиц или даже всей системы могут изменяться с течением времени. Unity предоставляет несколько различных способов указания как будет происходить изменение:-

  • Constant: Значение свойства не меняется со временем.
  • Curve: Значение меняется по кривой / графу.
  • Random between two constants: Два постоянных значения определяют верхнюю и нижнюю границы для итогового значения, которое выбирается случайно из всех значений, попадающих в эти рамки.
  • Random Between Two Curves: Two curves define the upper and lower bounds of the value at a given point in its lifetime; the current value varies randomly between those bounds.

When you set a property to Curve or Random Between Two Curves, the Particle System Curves editor appears at the bottom of the Inspector:

To edit a curve, click and drag an end point or key to reshape the curve:

Particle System curves are similar to Animation curves. For information on using curves, see the documentation on Editing Curves.

The Particle System Curves editor has the following buttons:

  • Optimize: Fits the curve into four or fewer keys to build a fast evaluator called a Polynomial, which is more efficient than reading the unoptimized curve.
  • Remove: Deletes the selected curve.

To edit the way in which the Particle System plays curves, click the cog next to a selected key and choose one of the following options:

  • Loop: Plays the curve the specified number times over a particle’s life. For example, if you make a curve that scales a particle’s size up and down, you can tell it to loop multiple times, which causes the “up and down” animation to happen multiple times before the particle dies, instead of just once.
  • Ping Pong: Similar to Loop, but plays the curve forwards then backwards in a continuous oscillation.
  • Clamp: Limits particle queries that fall outside the curve time range to the first or last value of the curve.

Similarly, the Start Color property in the main module has the following options:

  • Constant: Значение свойства не меняется со временем.
  • Gradient: Particles are emitted with a start color specified by a gradient, with the gradient representing the lifetime of the Particle System.
  • Random Between Two Colors: The starting particle color is chosen as a random linear interpolation between the two given colors.
  • Random Between Two Gradients: Two colors are picked from the given Gradients at the point corresponding to the current age of the Particle System; the starting particle color is chosen as a random linear interpolation between these colors.
  • Random Color: Picks any point at random from the Gradient for every newly spawned particle.

When you set the Gradient color for particles, the Gradient Editor appears:

  • Mode: Determines whether the particle color settings are blended or not.
  • Color: Displays the color of the currently selected key in the Gradient. Use this to edit the color at that position of the Gradient.
  • Location: Shows how far along on the Gradient the currently selected key is.
  • Presets: Allows you to save Gradient settings. Click New to make the current set of values a Gradient preset.

Color properties in various modules are multiplied together per channel to calculate the final particle color result.

Animation bindings

All particle properties are accessible by the Animation system, meaning you can keyframe them in and control them from your animations.

To access the Particle System’s properties, there must be an Animator component attached to the Particle System’s GameObject. An Animation Controller and an Animation are also required.

To animate a Particle System, add an Animator Component, and assign an Animation Controller with an Animation.
To animate a Particle System, add an Animator Component, and assign an Animation Controller with an Animation.

To animate a Particle System property, open the Animation Window with the GameObject containing the Animator and Particle System selected. Click Add Property to add properties.

Add properties to the animation in the Animation Window.
Add properties to the animation in the Animation Window.

Scroll to the right to reveal the add controls.

Note that for curves, you can only keyframe the overall curve multiplier, which can be found next to the curve editor in the Inspector.

  • 2018–11–27 Page amended with limited editorial review

  • GameObject menu changed in Unity 4.6

  • Particle System loop/ping-pong curve playing added in 2018.3 NewIn20183X

What is a Particle System?
Particle System How-Tos