Accessing a script of the child of a recent spawned object?

Hello all;

I’m spawning an object like so:

Instantiate (side1, pos, Quaternion.identity);

When a condition is met. However I want to access a script belonging to the child of it…

i tried this:

var boneScript : boneScript = gameObject.GetComponent(boneScript);
boneScript.angle = 270;

No luck though;

any ideas would be great.

thanks, Bobblehead.

gameObject.GetComponentInChildren(boneScript);

he actually never said that he is spawning the player.

what you could do is…

instead of just instantiate()…

save it as a gameobject. (not sure how that is done in js) but :

GameObject temp = Instantiate(…)as GameObject;
then you can simply access the components attached to that GameObject like so :

temp.GetComponentInChildren().angle = 270f;

that is all C# - but you should get the general idea.
As far as I know this way is more efficient than FindWithTag(…);