Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

I can't find an index inside my List.

$
0
0
In this scrip I am instantiateing Transforms then I put those into my class and then I add the class to an array and add the array to a List. My problem is that I anticipate the first row of objects spawning at position (-3 + i,0.1f,-1) and then when I instantiate the second row of objects the will spawn at the same position and the the movement function will move both rows down on the z axis so the both will be(-3+1,0.1f,-2). But what happens is that when the second row comes in it intantiates at (-3+1,0.1f,-3) and the first row stays at (-3+1,0.1f,-1). It is almost as if the List sees only one object inside it and apply's the movement function twice on the same object. Oke so here is a part of my script : void Update() { if(canSpawn) { Spawner(); Movement(); canSpawn = false; } } void Start() { Spawner(); } void Spawner() { for(int i = 0; i < 7; i++) { Vector3 startPos = new Vector3(-3 + i,0.1f,-1); Identity(); Transform newPlayPieceTemp = Instantiate(newPlayPiece, startPos, Quaternion.identity) as Transform; PlayPieceClass playPieceObject = new PlayPieceClass(startPos, newPlayPieceTemp, newId, false); insideArray[i] = playPieceObject; } playPieceList.Add(insideArray); } void Movement() { for(int i = 0; i < playPieceList.Count; i++) { for(int ii = 0; ii < 7; ii++) { playPieceList[i][ii].playPiece.transform.position -= new Vector3(0,0,1); } } } I hope someone can help me out! Thank you in advance!

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>