In this tutorial: Instantiate - Unity Learn
The tutor Instantiates a rigidbody type variable.
public class UsingInstantiate : MonoBehaviour
{
public Rigidbody rocketPrefab;
public Transform barrelEnd;
void Update ()
{
if(Input.GetButtonDown("Fire1"))
{
Rigidbody rocketInstance;
rocketInstance = Instantiate(rocketPrefab, barrelEnd.position, barrelEnd.rotation) as Rigidbody;
rocketInstance.AddForce(barrelEnd.forward * 5000);
}
}
}
- Why doesn’t he Instantiates the GameObject of the said rocket? (Prefabs refer to GameObject and not Components)
-Whats the meaning of giving Instantiatate a parameter that is a Component and not a GameObject?
And when should I use each of those?