Loop through Children Unable to Access Component Script

In the space shooter I’m designing, a dead ship spawns a bunch of ship fragments, which are supposed to drift apart and then disappear after a short time. To do that for my Slicer fighter, I have two scripts - SlicerFragElement, which is assigned to each of the child fragments, has velocity and angular velocity fields, and simply handles translating the frag it is assigned to. To set this up, I have the SlicerFragElement script, which is supposed to assign velocities to all of the individual frags. To do that, I have the following code (print statements are for debugging):

var startTime : float;
var duration : float = 5.0;

function Start () {
	startTime = Time.time;
	//*
	for (var child : Transform in this.transform) {
		var distanceVec : Vector3 = child.position - transform.position;
		//print(distanceVec);
		//print(child.name);
		child.GetComponent("SlicerFragElement").velocity = 
					Random.Range(5.0, 14.0) * (1 / Mathf.Pow(distanceVec.magnitude + .2, 2)) * distanceVec.normalized;
		//print(child.GetComponent("FalconFragElement").angularVel);
	}
	
}

function Update () {
	if (Time.time > startTime + duration) {
		Destroy(this.gameObject);
	}
}

The problem is, this code cannot seem to modify the SlicerFragElement scripts for any of the children. Their velocity stays at 0, the print statements show (0,0,0,0) and (0,0,0) for the angularVel and velocity, even when the angularVel (assigned in SlicerFragElement ) is nonzero. However, the names do show up correctly.

Any idea what the problem is? Also, would just assigning rigidbodies to each of the frag elements be more processor-efficient (there may be hundreds of these onscreen at once, so that’s a concern)?

Without the code for SlicerFragElement, it’s kind of hard to say.

My first suggestion is to simply set the velocity to some constant value, if you haven’t tried that already. If it’s still always zero, then I would suspect something in the SlicerFragElement code that is resetting it to zero.

At a much higher level though, you may want to use Unity’s particle system (Shuriken) for something like this anyway. If there’s no gameplay element to the fragments, then using Unity’s particle system will be much more efficient, and is less work in the long run.