입자(Particle) 시스템 (2D)¶
간단한(간단하지만 대부분 용도에 충분히 유연한) 입자 시스템이 제공됩니다. 입자 시스템은 스파크나 불, 마법 입자, 연기, 안개 등 복잡한 물리적 효과를 시뮬레이션하기 위해 쓰입니다.
The idea is that a "particle" is emitted at a fixed interval and with a fixed lifetime. During its lifetime, every particle will have the same base behavior. What makes each particle different from the rest and provides a more organic look is the "randomness" associated with each parameter. In essence, creating a particle system means setting base physics parameters and then adding randomness to them.
Godot provides two different nodes for 2D particles, Particles2D and CPUParticles2D. Particles2D is more advanced and uses the GPU to process particle effects, but that limits it to higher end graphics API, and in our case to the GLES3 renderer. For projects using the GLES2 backend, CPUParticles2D is a CPU-driven option with near feature parity with Particles2D, but lesser performance. While Particles2D is configured via a ParticlesMaterial (and optionally with a custom shader), the matching options are provided via node properties in CPUParticles2D (with the exception of the trail settings). You can convert a Particles2D node into a CPUParticles2D node by clicking on the node in the inspector, and selecting "Convert to CPUParticles2D" in the "Particles" menu of the toolbar.
The rest of this tutorial is going to use the Particles2D node. First, add a Particles2D node to your scene. After creating that node you will notice that only a white dot was created, and that there is a warning icon next to your Particles2D node in the scene dock. This is because the node needs a ParticlesMaterial to function.
입자 노드에 프로세스 재료(process material)을 추가하기 위해서 인스펙터(Inspecter) 패널에서
Process Material 로 갑니다.
Material 박스를 클릭한 다음 드롭다운 메뉴에서 ``New ParticlsMaterial``를 선택합니다.
Your Particles2D node should now be emitting white points downward.
A particle system uses a single texture (in the future this might be extended to animated textures via spritesheet). The texture is set via the relevant texture property:
입자가 머무는 시간(초). 수명(lifetime)이 끝나면 새로운 입자가 대체됩니다.
활성화되면 Particles2D 노드는 모든 입자를 한 번 방출하고 다시는 방출하지 않습니다.
Particle systems begin with zero particles emitted, then start emitting. This can be an inconvenience when loading a scene and systems like a torch, mist, etc. begin emitting the moment you enter. Preprocess is used to let the system process a given number of seconds before it is actually drawn the first time.
The speed scale has a default value of
1 and is used to adjust the
speed of a particle system. Lowering the value will make the particles
slower while increasing the value will make the particles much faster.
If lifetime is
1 and there are 10 particles, it means a particle
will be emitted every 0.1 seconds. The explosiveness parameter changes
this, and forces particles to be emitted all together. Ranges are:
0: 입자들을 일정한 간격으로 방출합니다(기본 값).
1: 동시에 모든 입자를 방출합니다.
Values in the middle are also allowed. This feature is useful for creating explosions or sudden bursts of particles:
All physics parameters can be randomized. Random values range from
1. The formula to randomize a parameter is:
initial_value = param_value + param_value * randomness
This setting can be used to set the particle system to render at a fixed
FPS. For instance, changing the value to
2 will make the particles render
at 2 frames per second. Note this does not slow down the particle system itself.
This can be used to turn Fract Delta on or off.
The visibility rectangle controls the visibility of the particles on screen. If this rectangle is outside of the viewport, the engine will not render the particles on screen.
H properties respectively control its Width and its Height.
Y properties control the position of the upper-left
corner of the rectangle, relative to the particle emitter.
You can have Godot generate a Visibility Rect automatically using the toolbar above the 2d view. To do so, select the Particles2D node and Click
Particles > Generate Visibility Rect. Godot will simulate the Particles2D node emitting particles for a few seconds and set the rectangle to fit the surface the particles take.
You can control the emit duration with the
Generation Time (sec) option. The maximum value is 25 seconds. If you need more time for your particles to move around, you can temporarily change the
preprocess duration on the Particles2D node.
By default this option is on, and it means that the space that particles are emitted to is relative to the node. If the node is moved, all particles are moved with it:
If disabled, particles will emit to global space, meaning that if the node is moved, already emitted particles are not affected:
This controls the order in which individual particles are drawn.
means particles are drawn according to their emission order (default).
Lifetime means they are drawn in order of remaining lifetime.
This is the base direction at which particles emit. The default is
Vector3(1, 0, 0) which makes particles emit to the right. However,
with the default gravity settings, particles will go straight down.
For this property to be noticeable, you need an initial velocity greater than 0. Here, we set the initial velocity to 40. You'll notice that particles emit toward the right, then go down because of gravity.
This parameter is the angle in degrees which will be randomly added in
either direction to the base
Direction. A spread of
180 will emit
in all directions (+/- 180). For spread to do anything the "Initial Velocity"
parameter must be greater than 0.
This property is only useful for 3D particles.
The gravity applied to every particle.
초기 속도(Initial Velocity)¶
Initial velocity is the speed at which particles will be emitted (in pixels/sec). Speed might later be modified by gravity or other accelerations (as described further below).
Angular velocity is the initial angular velocity applied to particles.
회전 속도(Spin Velocity)¶
Spin velocity is the speed at which particles turn around their center (in degrees/sec).
공전 속도(Orbit Velocity)¶
공전 속도는 입자들이 중심을 돌게 만드는 데 사용됩니다.
선형 가속도(Linear Acceleration)¶
각 입자에 적용되는 선형 가속도.
지름 가속도(Radial Acceleration)¶
If this acceleration is positive, particles are accelerated away from the center. If negative, they are absorbed towards it.
This acceleration will use the tangent vector to the center. Combining with radial acceleration can do nice effects.
Damping은 입자에 마찰을 일으켜 멈추게 합니다. 특히 불꽃이나 폭발에 유용하며 보통 높은 선형 속도로 시작하다가 점차 사라지면서 멈춘다.
Determines the initial angle of the particle (in degrees). This parameter is mostly useful randomized.
Determines the initial scale of the particles.
방출되는 입자 색깔을 바꾸는 데 사용됩니다.
Variation value sets the initial hue variation applied to each
Variation Random value controls the hue variation
방출 모양(Emission Shapes)¶
ParticlesMaterials allow you to set an Emission Mask, which dictates the area and direction in which particles are emitted. These can be generated from textures in your project.
ParticlesMaterial이 설정되고 Particle2D 노드가 선택되어 있는지 확인하십시오. 툴바에 "파티클(Particles)" 메뉴가 표시됩니다:
메뉴를 열고 "에미션 마스크 불러오기"를 선택하세요:
그런 다음 마스크로 쓸 텍스처를 선택합니다:
몇 가지 설정이 있는 대화 상자가 나타납니다.
텍스처로 생성될 수 있는 에미션 마스크는 세 가지 유형이 있습니다:
Solid Pixels: 텍스처의 투명한 부분을 제외한 모든 영역에서 입자가 생겨납니다.
Border Pixels: 텍스처의 바깥쪽 가장자리에 입자가 생겨납니다.
Directed Border Pixels: Border Pixels와 유사하지만 마스크에 추가 정보를 추가하여 입자들이 경계에서 멀리 방출할 수 있는 능력을 부여한다. 이를 활용하려면 ``초기 속도``를 설정해야 합니다.