Could be also the screen but also the terrain.
The idea is to instantiate gameobjects from the left side to the right.
I have 4 cubes i positioned them manual from the left terrain edge side to the right.
I have a empty gameobject with this script:
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
public class ClickOn : MonoBehaviour
{
public GameObject[] prefabs;
public int gap = 10;
private GameObject go;
private GameObject tests;
void Start()
{
prefabs = Resources.LoadAll("Prefabs", typeof(GameObject)).Cast<GameObject>().ToArray();
foreach (GameObject prefab in prefabs)
{
if (prefab.name == "My Prefabs")
{
go = prefab;
}
}
tests = GameObject.Find("Testing");
}
void Update()
{
if (Input.anyKey)
{
foreach (Transform child in go.transform)
{
if (Input.inputString == child.name)
{
Transform clone = Instantiate(child, new Vector3(gap += 50, 0, 0), Quaternion.identity);
clone.parent = tests.transform;
}
}
}
}
}
The problem is that is when i click the keys some of them it’s positioning the gameobject from the right side to he left.
So the first gameobject will be cube(1) on the right then cube(2)…cube(4)
So it’s also positioning it from the right side and also with the wrong order.
I want to find calculate the terrain left edge and to start position the gameobject from the left side: Cube(1),Cube(2),Cube(3),Cube(4)
And then but this is option but if the last cube is getting close enough to the right edge like pressing enter move down and start position again from the right edge.