diff --git a/Assets/Scripts/CannonScript.cs b/Assets/Scripts/CannonScript.cs index 8105601..189b9bb 100644 --- a/Assets/Scripts/CannonScript.cs +++ b/Assets/Scripts/CannonScript.cs @@ -30,7 +30,6 @@ public class CannonScript : MonoBehaviour void Update() { Debug.DrawRay(transform.position, lookDir * Mathf.Infinity, Color.red); - Debug.Log(EventSystem.current.IsPointerOverGameObject()); if (firing && !EventSystem.current.IsPointerOverGameObject()){ fireTimer += Time.deltaTime; diff --git a/Assets/Scripts/DimensionController.cs b/Assets/Scripts/DimensionController.cs index 7f7e130..5018a75 100644 --- a/Assets/Scripts/DimensionController.cs +++ b/Assets/Scripts/DimensionController.cs @@ -15,6 +15,7 @@ public class DimensionController : MonoBehaviour private void OnTriggerEnter(Collider other) { + StartCoroutine(other.GetComponent().InstantDestroy()); if (_hp <= 0) { return; } var enemy = other.GetComponent(); @@ -22,9 +23,6 @@ public class DimensionController : MonoBehaviour // Update HP (temp for now) _hp -= enemy.DamageDealt(); - - // Destroy projectile - Destroy(other.gameObject); GameManager.Instance.DealDamage(dimensionId, _hp, _maxHp); } diff --git a/Assets/Scripts/Enemy.cs b/Assets/Scripts/Enemy.cs index 3d75b8b..e92a11f 100644 --- a/Assets/Scripts/Enemy.cs +++ b/Assets/Scripts/Enemy.cs @@ -68,6 +68,18 @@ public class Enemy : MonoBehaviour Destroy(gameObject); } + public IEnumerator InstantDestroy() + { + gameObject.GetComponent().velocity = gameObject.transform.forward * (flyingSpeed / 3); + body.SetActive(false); + explosion.Emit(100); + explosionDebris.Emit(40); + yield return new WaitForSeconds(.1f); + collider.enabled = false; + yield return new WaitForSeconds(1f); + Destroy(gameObject); + } + IEnumerator playDmgParticles(float waitTime) { yield return new WaitForSeconds(waitTime);