particles on hit planet

This commit is contained in:
louishorlaville 2022-05-15 16:37:14 -04:00
parent 14f3a2dda5
commit f61dbb9edd
3 changed files with 13 additions and 4 deletions

View File

@ -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;

View File

@ -15,6 +15,7 @@ public class DimensionController : MonoBehaviour
private void OnTriggerEnter(Collider other)
{
StartCoroutine(other.GetComponent<Enemy>().InstantDestroy());
if (_hp <= 0) { return; }
var enemy = other.GetComponent<Enemy>();
@ -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);
}

View File

@ -68,6 +68,18 @@ public class Enemy : MonoBehaviour
Destroy(gameObject);
}
public IEnumerator InstantDestroy()
{
gameObject.GetComponent<Rigidbody>().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);