Need a little Help,
I have created a group named “GameBlocks” of 12 cubes with no rigidbody named as Strip5…Strip16. My GameBlocks group has rigidbody attached to it. The standard DragRigidbody script of Unity works fine on this group.
But when i instantiate a new object from an object within the group and make it a child of the group it stops working on the group. Can some one tell me what i am doing wrong. I am new to Unity.
Here is my code,
var blocks: GameObject[];
var rightEdge:GameObject;
var parentBlock:GameObject;
function OnTriggerEnter(other: Collider)
{
var i:int;
var j:int;
var tempBlock:GameObject;
if(this.name=="Edge4Collider")
{
Destroy(blocks[0]);
for(i=0;i<11;i++)
{
blocks[i]=blocks[i+1];
}
blocks[i]=Instantiate(blocks[1],blocks[1].transform.position,blocks[1].transform.rotation);
blocks[i].transform.parent=parentBlock.transform;
blocks[i].transform.position.x= blocks[i-1].transform.position.x+1;
}
The cubes Strip5…Strip16 are attached to the array blocks[ ]. GameBlocks group is attached to parentBlock. Please tell me if more information is needed.