- Home /
How can i keep global scale of object while instantiate it
Hi I have a gameobject which name is gridBuildList I attach gameObjects in it because adding each element to list with hand is so tiring
Then i attach these gameObjects to a list which name is gridBuild with that loop
public GameObject gridBuildList;
public List<GameObject> gridBuild = new List<GameObject>();
foreach (Transform a in gridBuildList.GetComponent<Transform>())
{
gridBuild.Add(a.gameObject);
}
Finally I have a grid tile list i spawn my buildings on these grid tiles
for (int i = 0; i < tiles.Count; i++)
{
Vector3 gridTile = tiles[i].transform.position;
var spawnedTle = Instantiate(gridBuild[Random.Range(0,gridBuild.Count)], gridTile, Quaternion.identity);
}
Briefly i spawn random gameObjects from gridBuild list on gridTile positions
My problem is scale is wrong, black tile is grid i spawn object on it
this is how it should work
spawnedTle.transform.localScale = new Vector3(4.5f, 4.5f); (i get this result with these code but it isn't reliabe solution)
https://imgur.com/a/1njbsUK (Forum don't let me upload more than 2 photos)
Your answer
Follow this Question
Related Questions
Change grid scale or scale whole library 0 Answers
Vector3.MoveTowards doesnt work 1 Answer
Grid Letter Box is not expanding, 0 Answers
How to scale a GUI (Lagacy) grid? 1 Answer
Assertion failed on expression: 'goodPathName.find("assets/") != 0' 0 Answers