I’m trying to detonate a nuke that enables my invisible cube. When enemy collides with the cube and the explosion happened kill the enemy. But it kills the enemy before i detonate the nuke? I’ve been messing with this for a few days.
In update of projectile.
if(Input.GetKey("x"))
{
isExplode = true;
Instantiate(nukeBlastParticle, transform.localPosition, Quaternion.identity);
nukeShell.renderer.enabled = false;
audio.PlayOneShot(nukeBlast,0.7F);
if( nukeShell.renderer.enabled ==false)
//if(!nukeBlastParticle.activeInHierarchy){
{
// nukeBlastParticle.SetActive(true);
audio.PlayOneShot(nukeBlast,0.7F);
//enable renderer
// nukeShell.renderer.enabled = true;
}
}
in start of enemys health
explodeScript = GameObject.Find("nukeShell").GetComponent<NukeDetonate>(); //Find main game script
in update on my enemy’s health script.
void OnCollisionEnter( Collision collision)
{
if(gameObject.tag ==("nukeCube") explodeScript.isExplode == true)
{
enemy1Health = enemy1Health - 300.0f;
//Destroy(gameObject);
}
Now I’ve tried to declare a public gameobject and drag the cube onto prefab then do nukeCube.SetActive(true); But that doesn’t work and wont even let me drag the obj onto the public game object slot…