Say I had a prefab called Bullet
with a script attached called BulletControl.cs
.
I could instantiate it as: GameObject bulletInstance = Instantiate(Bullet, transform);
Or I could do: BulletControl bulletInstance = Instantiate(Bullet, transform);
I originally thought that instantiating as a GameObject
was just a more general type that gave you access to other parameters like transform. Instantiating, to my understanding, isn't like using the new
keyword, so I don't think that when I declare bulletInstance's type I'm creating an instance of the class BulletControl. What's going on here?