I’m making a RTS game like Total War in which the units are in groups, and to handle this I’m spawning units when the scene starts, and I want them to be parented to the “group” object.
var unitMax : int;
var unitStrength : int;
var unitType : Transform;
function Start () {
for (var i : int = 0;i < unitStrength; i++) {
Instantiate (unitType, Vector3(i * 2.0, 1, 0), Quaternion.identity);
unitType.transform.parent = gameObject.transform;
}
}
My problem is that the units aren’t children of the group object.