Local Var Sparkles. Why?

Hi everyone!
In this lecture we declared a variable called “blockSparkleVFX” to reference the VFX prefab in the inspector.

In the Method to actually instantiate the particle, we created a local variable call “sparkles”.

How is different to just use “blockSparkleVFX” instead of the local variable?

I know this is more code logic and seen it through the course, but i doubt I´ll know the correct way when working on other projects.

My code:
[SerializeField] GameObject blockSparkleVFX;

private void TriggerSparkVFX()
{
    blockSparkleVFX= Instantiate(blockSparkleVFX, transform.position, transform.rotation);
    Destroy(blockSparkleVFX, 2f);
}
3 Likes

Privacy & Terms