unity instantiate as a gameobject code example
Example 1: unity instantiate
clone = Instantiate(original);
clone = Instantiate(original, new Vector3(0, 0, 0), Quaternion.identity, cloneParent.transform);
Example 2: untiy instanciate prefab
Instantiate(prefab, new Vector3(i * 2.0F, 0, 0), Quaternion.identity);
Example 3: how to instantiate a gameobject
public void AddGameObject()
{
GameObject testPrefab = new GameObject("Name_1");
Vector3 objectPOS = Vector3.zero;
GameObject newGameObject = Instantiate(testPrefab, objectPOS, Quaternion.identity);
}
Example 4: unity instantiate vector3
using UnityEngine;
{
{
if (Input.GetButtonDown("Fire1"))
{
Rigidbody clone;
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection(Vector3.forward * 10);
}
}
}