public void dieInSpace() { if (!killable.isDead()) { kill(); flyParticles.Stop(); GetComponent <Rigidbody>().velocity = new Vector3(0f, 0f, 0f); GameObject newEffect = GameObject.Instantiate(explosionOnDieInSpacePrefab) as GameObject; newEffect.transform.position = transform.position; timeHasNotBeenBreathing = 0f; } }
// Update is called once per frame void Update() { if (killable.isDead() && !isDespawned) { OnEnemyDead(); } timerCheckPlayerDistance += Time.deltaTime; if (timerCheckPlayerDistance > Constants.TIME_BETWEEN_CHECK_PLAYER_DISTANCE_FOR_DESPAWN) { timerCheckPlayerDistance = 0f; if (Vector3.Distance(GameManager.player.transform.position, transform.position) > Constants.SPAWNING_MAXIMUM_DISTANCE_OF_PLAYER && !isDespawned) { //Debug.Log("Despawned"); OnDespawn(); } } }