Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using UnityEngine;
- [RequireComponent(typeof(Weapon))]
- public class WeaponParticleEffects : MonoBehaviour
- {
- [SerializeField] private float _lifeTime = 3f;
- [SerializeField] private GameObject _effectPrefab;
- private Weapon _weapon;
- private void Awake()
- {
- _weapon.OnFire += OnWeaponFire;
- }
- private void OnDestroy()
- {
- _weapon.OnFire -= OnWeaponFire;
- }
- private void OnWeaponFire()
- {
- var effect = Instantiate(_effectPrefab, _weapon.transform.position, Quaternion.identity, _weapon.transform);
- Destroy(effect, _lifeTime);
- }
- }
Add Comment
Please, Sign In to add comment