Scriptum/Assets/TreeParticleEffect.cs

29 lines
649 B
C#
Raw Permalink Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TreeParticleEffect : MonoBehaviour
{
public ParticleSystem collisionParticleSystem;
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.tag == "AttackHitbox")
{
var em = collisionParticleSystem.emission;
em.enabled = true;
collisionParticleSystem.Play();
StartCoroutine(Timer());
}
}
IEnumerator Timer()
{
yield return new WaitForSeconds(2.5f);
var em = collisionParticleSystem.emission;
em.enabled = false;
}
}