Суть: есть массив объектов, создаваемых скриптом. Нужно подвинуть определенный объект из массива. Однако всегда двигается п
оследний созданный объект. Что за ерунда?
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public GameObject myPrefab;
public Material mat;
public GameObject[,] ar = new GameObject[10, 10];
void Start ()
{
for (int i=1; i<7; i++)
{
for (int j=1; j<7; j++)
{
ar[j,i]=myPrefab;
Instantiate(ar[j,i]);
ar[j,i].transform.position = new Vector3(j*20-20,i*20-20,150);
ar[j,i].transform.eulerAngles = new Vector3(180, 0, 0);
ar[j,i].name="ob"+i+j;
}
}
ar[5,1].transform.position += new Vector3(100, 20, 3);//двигается не "ob51" а объект "ob66"
}
// Update is called once per frame
void update () { }
}