Hello everyone I have a 3D object which is an airplane, I want it to have about 3 lives, and re spawns when dies in a certain point that works fine everything is working fine but 1 thing, which is when it dies it doesn’t disappear even after the particle works which is the explosion one?
here’s the script and the object picture
using UnityEngine;
using System.Collections;
public class LevelManager : MonoBehaviour {
public GameObject currentCheckpoint;
public GameObject deathParticle;
public GameObject respawnParticle;
public GameObject bulletbonus;
private PlayerController player;
public int pointPenaltyOnDeath;
public float respawnDelay;
public HealthManager healthMnager;
void Start ()
{
player = FindObjectOfType<PlayerController> ();
healthMnager = FindObjectOfType<HealthManager> ();
}
void Update ()
{
if (player.enabled == false)
{
Destroy(GameObject.FindGameObjectWithTag("MonsterBulletSystem"));
Destroy(GameObject.FindGameObjectWithTag("EnemyMissile"));
Destroy(GameObject.FindGameObjectWithTag("Enemy"));
StopSuperShooter();
}
}
public void RespawnPlayer()
{
StartCoroutine ("RespawnPlayerCo");
}
public IEnumerator RespawnPlayerCo()
{
Instantiate (deathParticle, player.transform.position, player.transform.rotation);
player.enabled = false;
player.GetComponent<MeshRenderer> ().enabled = false;
//ScoreManager.AddPoints (-pointPenaltyOnDeath);
Debug.Log ("Player Respawn");
yield return new WaitForSeconds (respawnDelay);
player.transform.position = currentCheckpoint.transform.position;
player.enabled = true;
player.GetComponent<MeshRenderer> ().enabled = true;
healthMnager.FullHealth();
healthMnager.isDead = false;
Instantiate (respawnParticle, player.transform.position, player.transform.rotation);
}
void StopSuperShooter ()
{
bulletbonus.gameObject.SetActive(false);
}
}
Thanks in advance, what I need is to .enable false and I already set the meshrenderer to be false.