using System.Collections; using System.Collections.Generic; using UnityEngine; public class CharacterVFXManager : MonoBehaviour { public GameObject punchHitFXPrefab; public GameObject kickHitFXPrefab; //public ParticleSystem block_FX; public GameObject blockFXPrefab; // Start is called before the first frame update public void playPunchEffect(GameObject fxLocation) { Vector3 hitFX_Pos = fxLocation.transform.position; GameObject hitFX = Instantiate(punchHitFXPrefab, hitFX_Pos, Quaternion.identity); StartCoroutine(destroyHitFX(hitFX)); } public void playKickEffect(GameObject fxLocation) { Vector3 hitFX_Pos = fxLocation.transform.position; GameObject hitFX = Instantiate(kickHitFXPrefab, hitFX_Pos, Quaternion.identity); StartCoroutine(destroyHitFX(hitFX)); } public void playBlockEffect(GameObject fxLocation) { Vector3 blockFX_Pos = fxLocation.transform.position; GameObject blockFX = Instantiate(blockFXPrefab, blockFX_Pos, Quaternion.identity); StartCoroutine(destroyHitFX(blockFX)); //block effect is destroyed by a script attached to it //block_FX.Play(); } //destroy instantiated prefab in 10 secs IEnumerator destroyHitFX(GameObject hitFX) { yield return new WaitForSeconds(1f); Destroy(hitFX); } }