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: