[Memo-Unity] 14. ParticleSystem
์นดํ ๊ณ ๋ฆฌ: MeMo Unity
ํ๊ทธ: C#, MeMo Unity
ParticleSystem
MaskLayer
1. ํํฐํด ์์คํ
- ํํฐํด ์์คํ ์ ์ ์ฒ๊ฐ์ ์์ 2D ๋๋ 3D ์ค๋ธ์ ํธ๋ค์ ๊ด๋ฆฌํ๊ณ , ๊ทธ๋ค์ ๋์๊ณผ ์์ ๋ฅผ ์ ์ด
- ์ฃผ์ ์ปดํฌ๋ํธ๋ โemitterโ(๋ฐ์ฌ์ฒด), โparticlesโ(ํํฐํด), โanimatorโ(์ ๋๋ฉ์ดํฐ), โrendererโ(๋ ๋๋ฌ) ๋ฑ
ํํฐํด
ParticleSystem
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();
}
}
}
์ ๋๋ฉ์ด์
์ด๋ฒคํธ ์ถ๊ฐ
ํ๊ฒฉ ์ ํํฐํด
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
SetBurst
new PaticleSystem.Burst
์ ๋ฆฌ
[Unity] ParticleSystem
TOP
๋๊ธ๋จ๊ธฐ๊ธฐ