Question by
PhantomMagic · Jul 19, 2016 at 07:32 PM ·
instantiatedestroyspawn
I'm trying to spawn an object once another object has been destroyed how do i do that.
public class SpawnFire : MonoBehaviour { public bool iscreated = false; public GameObject Smallfire;
void OnCollisionEnter (Collision col)
{
if (col.gameObject.name == "GameFire") {
Destroy (col.gameObject);
iscreated = true;
}
}
void update()
{
if (iscreated)
{
Debug.Log ("smal fire has spawned!!");
Quaternion spawnRotation = Quaternion.identity;
Vector3 spawnPosition = new Vector3 (
0, 0, -6.5f);
Instantiate (Smallfire, spawnPosition, spawnRotation);
iscreated = false;
}
}
}
Comment
Answer by JamesLawrenceMyQVO · Jul 19, 2016 at 07:44 PM
Is this script on the object that is getting destroyed by the: Destroy (col.gameObject); ? If so, the script won't be around in order to spawn something. To handle that, you would have to spawn the new object before destroying the old object.
Answer by PhantomMagic · Jul 25, 2016 at 04:10 PM
thats what im trying to figure out but idk how im trying to switch the object after its hit