I'm very beginner of unity. I wanna instantiate gameObject in script without cloning already existed GameObject by editor. When I saw tutorial in unity3d.com of which code at below, I was curious why rigid body is instantiated.
As I know rigid body is a component of GameObject and child component of GameObject in conceptually. Even though, rigidbody is instantiated only, instance of game object is shown in the scene during playing.
Thanks, in advance.
using UnityEngine;
using System.Collections;
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);
}
}
}