I am working on a small project . But now I have come across a problem . The problem is the prefab is instantiating on the same position .
I want to instantiate a box end to end . The basic set up is as follows : -
Image 3 – http://s10.postimg.org/a2cqtappl/image.png
Box game object has a parent empty object (Start_point) , and a child empty object (end point) . Those marks the Start and End of that game object .
The game a empty game object (Tile_Gen) which has a C# script as follows :-
using UnityEngine;
using System.Collections;
public class Tile_Gen : MonoBehaviour
{
public GameObject G_O_01 ;
public GameObject Current_Tile ;
public Vector3 Start_Position_Of_Path ;
// Use this for initialization
void Start ()
{
Start_Position_Of_Path = Current_Tile.transform.GetChild(0).transform.GetChild(0).position;
Instantiate(Current_Tile , Start_Position_Of_Path , Quaternion.identity);
}
// Update is called once per frame
void Update ()
{
Path_Generator ();
}
public void Path_Generator()
{
Instantiate(G_O_01 , Start_Position_Of_Path , Quaternion.identity);
// End of tile position = start tile position
Start_Position_Of_Path = G_O_01.transform.GetChild(0).transform.GetChild(0).position;
print (Start_Position_Of_Path);
}
}
Here G_O_01 is Start_point prefab , Current_Tile is Start_point .
But this is not instantiating as I wanted . This instantiates all the object at one place .
But I want something like one behind the another , like this :-
Image 4 – http://s9.postimg.org/ctwm25m5b/image.png
So Please help me to figure it out .
Regards NB