Reafy
1
This script makes a clone but the clone spawns far below the terrain. How can i fix this?
#pragma strict
var prefab : Transform;
function Update ()
{
if (Input.GetKeyDown("g"))
{
for (var i : int = 0;i < 1; i++)
{
Instantiate (prefab, Vector3(i * 2.0, 0, 0), Quaternion.identity);
}
}
}
1 Answer
1
You can take an empty game object and place that object to a position where do you want to instantiate an object clone.
#pragma strict
var prefab : Transform;
var refObject : GameObject;
function Update ()
{
if (Input.GetKeyDown("g"))
{
for (var i : int = 0;i < 1; i++)
{
Instantiate (prefab, refObject.transform.position , Quaternion.identity);
}
}
}
Assign empty gameobject to refObject variable.
You can use this idea.