Question by
Trash_C4t · Feb 11, 2021 at 09:18 PM ·
instantiateparticlesinstantiate prefab
Instantiate Causes errors when I spawn multiple particle prefabs at once.
I have a C4 object in my game where if you press G they should all explode and spawn a particle prefab. They do explode, but it freezes the game for a short second and causes 3 errors in the console. I am using Unity 3d with HDRP.
Code:
void Update()
{
if (connected & !hasExploded & Input.GetKeyDown(KeyCode.G))
{
hasExploded = true;
Explode();
}
}
void Explode()
{
Instantiate(explosionEffect, transform.position, transform.rotation);
Destroy(gameObject);
}
Errors:
errors.png
(19.9 kB)
Comment
Answer by Trash_C4t · Feb 11, 2021 at 09:25 PM
Found the error right as I posted this. The error is the light in the particle prefab and somehow it's messing with the instantiate.