hello everyone, i am trying to make a space engineers like game, its supposed that you wiull be able to create your own vehicles, bases, weapos, etc. in a minecraft block placing sort of way. the script im having problems with is supposed to categorize the block that has been placed inside an array. that way i will be able to know how many engines will aplly thrust, how much will it weigh, and other sort of important stuff. i am trying to categorize them the following way:
using UnityEngine;
using System.Collections;
public class Cube_manage : MonoBehaviour {
public Transform selectedChild;
public Transform[] chasiBlocks;
public Transform[] gyroscopes;
public Transform[] engines;
void Update () {
for (int i = 0; i < transform.childCount; i++){
selectedChild = transform.GetChild(i);
if (selectedChild.tag == "Engine"){
selectedChild = engines[engines.Length ++];
break;
}
if (selectedChild.tag == "Chasi"){
selectedChild = chasiBlocks[chasiBlocks.Length ++];
break;
}
if (selectedChild.tag == "Gyro"){
selectedChild = gyroscopes[gyroscopes.Length ++];
break;
}
}
}
}
when a block is placed its automaticaly asigned to an empy object containing all the blocks of that spesific vehicle. all i have to do is to check the newly placed block’s tag and that way it will put it in a array. i do not now how to make tis work, what yous ee above is the only thing that came to my mind. if you can give me any tips or ides on how to fix the code it will be much apreciated.
kind regards,
Thenachotech