I am using the following code to create a line of prefabs
{
public GameObject myPrefab;
Vector3 lastPosition = new Vector3(0,2,0);
Vector3 offsetVector = new Vector3(0,0,-3);
void Update()
{
if(Input.GetKeyDown (KeyCode.Space))
{
GameObject myPrefabInstance = GameObject.Instantiate(myPrefab, lastPosition + offsetVector, Quaternion.identity);
lastPosition = myPrefabInstance.transform.position;
}
}
}
This works great and gives me a nice even row of prefabs. However I want the player to be able to adjust the position of each prefab once it is placed and have an arrow key move script attached to the parent prefab. Of course this means that currently all the prefabs move in unison. How do I disable the previous prefab (perhaps with SetActive = false) once the space bar is pressed and the next prefab is placed. Currently I only want the player to be able to move each prefab once.
Thanks for any suggestions.