[Memo-Unity] 14. ParticleSystem

์—…๋ฐ์ดํŠธ:

์นดํ…Œ๊ณ ๋ฆฌ:

ํƒœ๊ทธ: ,


ParticleSystem

MaskLayer








1. ํŒŒํ‹ฐํด ์‹œ์Šคํ…œ

  • ํŒŒํ‹ฐํด ์‹œ์Šคํ…œ์€ ์ˆ˜ ์ฒœ๊ฐœ์˜ ์ž‘์€ 2D ๋˜๋Š” 3D ์˜ค๋ธŒ์ ํŠธ๋“ค์„ ๊ด€๋ฆฌํ•˜๊ณ , ๊ทธ๋“ค์˜ ๋™์ž‘๊ณผ ์ƒ์• ๋ฅผ ์ œ์–ด
  • ์ฃผ์š” ์ปดํฌ๋„ŒํŠธ๋Š” โ€˜emitterโ€™(๋ฐœ์‚ฌ์ฒด), โ€˜particlesโ€™(ํŒŒํ‹ฐํด), โ€˜animatorโ€™(์• ๋‹ˆ๋ฉ”์ดํ„ฐ), โ€˜rendererโ€™(๋ Œ๋”๋Ÿฌ) ๋“ฑ

ํŒŒํ‹ฐํด ParticleSystem
image

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DustParticleControl : MonoBehaviour
{
    [SerializeField] private bool createDustOnWalk = true;
    [SerializeField] private ParticleSystem dustParticleSystem;

    public void CreateDustParticles()
    {
        if (createDustOnWalk)
        {
            dustParticleSystem.Stop();
            dustParticleSystem.Play();
        }
    }
}

์• ๋‹ˆ๋ฉ”์ด์…˜ ์ด๋ฒคํŠธ ์ถ”๊ฐ€
image
image

ํƒ€๊ฒฉ ์‹œ ํŒŒํ‹ฐํด

ProjectileManager ์ˆ˜์ •
public void CreateImpactParticlesAtPostion(Vector3 position, RangedAttackData attackData)
{
    _impactParticleSystem.transform.position = position;
    ParticleSystem.EmissionModule em = _impactParticleSystem.emission;
    em.SetBurst(0, new ParticleSystem.Burst(0, Mathf.Ceil(attackData.size * 5)));
    ParticleSystem.MainModule mainModule = _impactParticleSystem.main;
    mainModule.startSpeedMultiplier = attackData.size * 10f;
    _impactParticleSystem.Play();
}
โ€‹
RangedAttackController ์ˆ˜์ •
private void DestroyProjectile(Vector3 position, bool createFx)
{
    if(createFx)
    {
        _projectileManager.CreateImpactParticlesAtPostion(position, _attackData);
    }
    gameObject.SetActive(false);
}

Particle System-Emission
image

SetBurst image

new PaticleSystem.Burst image








์ •๋ฆฌ

์ฐธ๊ณ 




[Unity] ParticleSystem TOP


๐Ÿ“”

๋Œ“๊ธ€๋‚จ๊ธฐ๊ธฐ