[Suggestion] smokePuff declaration and cast type

In lecture 95, where particles are intruduced, I wonder why do we declare smokePuff instance as GameObject?
GameObject smokePuff = Instantiate(...) as GameObject;

How do we benefit from it being GameObject? If we have a script attached to Smoke, we can’t even use its methods. Wouldn’t it be wiser to code it like that:

Smoke smokePuff = Instantiate(...) as Smoke; //then for example call a method created in Smoke script smokePuff.SetColor(brickColor);

I personally coded it like that and in my opinion it works much better this way. Could someone explain me advantages of using GameObject type instead our Class type?

I am having difficulty trying to get it to work AT ALL let alone seeing a different type of coding.

I think the idea is to make it faster using the Instantiate and I managed to figure that part out, but getting the colour on the bricks? Impossible with the current coding method and no idea how to fix that.

After looking at the code, and I am still very much a beginner at this, I was wondering the same thing about creating the new GameObject when:

smoke.particleSystem.startColor does the same thing, and we aren’t creating a new GameObject.

Privacy & Terms