private void OnCollisionEnter(Collision collision) { _effect.DestroyEffect(); var e = Instantiate(_hitEffect, transform.position, transform.rotation); e.Invoke(nameof(e.DestroyEffect), 3); Destroy(gameObject); }
public GameObject PlayEffect(E_EFFECT effect, Vector3 pos, Quaternion quat, bool isInstance = true, float DestroyTime = 2.0f, Transform tr = null) { GameObject effectObject = PoolingManager.Instance.PopFromPool(effect.ToString(), pos, quat); if (effectObject == null) { return(null); } EffectObject effectObj = Common.GetOrAddComponent <EffectObject>(effectObject); if (effectObj != null) { if (isInstance) { effectObj.DestroyEffect(DestroyTime); } if (tr != null) { effectObj.AttachToTransform(tr, Vector3.zero); } } return(effectObject); }
private void Start() { _effect = GetComponentInChildren <EffectObject>(); Observable.Timer(TimeSpan.FromSeconds(LifeTime)).Subscribe(_ => { _effect.DestroyEffect(); Destroy(gameObject); }).AddTo(this); }
private void OnHit() { if(_effect) _effect.DestroyEffect(); var e = Instantiate(_hitEffect, transform.position, transform.rotation); e.Invoke(nameof(e.DestroyEffect), 3); Destroy(gameObject); Audio.AudioManager.PlaySE("beamgun2", position: transform.position); }