Hi, I don’t really have a problem with the lecture but I have a query about the code.
Why does this work:
[SerializeField] GameObject Weapon;
void SetWeaponActive(bool active)
{
var emmisionMod = Weapon.GetComponent<ParticleSystem>().emission;
emmisionMod.enabled = active;
}
While this throws an error:
[SerializeField] GameObject Weapon;
void SetWeaponActive(bool active)
{
Weapon.GetComponent<ParticleSystem>().emission.enabled = active;
}
What does putting the component inside a variable actually do that makes it different?