Unable to assign prefabs target at runtime

I'm currentley trying to assign the target of a script attached to one of my prefabs, the idea being that i will be able to spawn the prefab and its script will grab its target. The prefab is set as the child of an empty gameobject, which i'm using to assign the target variable of the prefab with this piece of code:

    function Awake ()
{
    transform.Find("tornadogameobject").GetComponent("newgrav").varplanet = "Sphere";
}

The Gameobject "Sphere" is permanently in the scene hierarchy. I'm really struggling to figure out why the "Sphere" Gameobject currently isn't being assigned as th target when the game is running and i can't think of a differnet way to do it considering i can't assign the prefabs target before its spawned. If anyone could show me were i'm going wrong i'd be extremely gratefull, been struggling with this for a couple of days now.

Edit:

here's the code i will be using for the spawning:

function OnTriggerEnter(other:Collider)

{ var spawn:SpawnPoint = other.GetComponent(SpawnPoint);

if(spawn) spawn.DoSpawn(); }

and heres the code i am using to make the tornadogameobject prefab rotate around the Sphere

var rotationSpeed = 120.0;

var translationSpeed = 10.0; var height = 2.0; //height from ground level private var centre : Transform; //transform for planet private var radius : float; //calculated radius from collider var planet : SphereCollider; //collider for planet

function Start ()

{
    //consider scale applied to planet transform (assuming uniform, just pick one)
    radius = planet.radius * planet.transform.localScale.y;
    centre = planet.transform;
    //starting position at north pole
    transform.position = centre.position + Vector3(0,radius+height,0);
}

function Update ()

{
    //translate based on input
    var inputMag  = Input.GetAxis("Fire1")*translationSpeed*Time.deltaTime;
    transform.position += transform.forward * inputMag;
    //snap position to radius + height (could also use raycasts)
    targetPosition = transform.position - centre.position;
    var ratio = (radius + height) / targetPosition.magnitude;
    targetPosition.Scale(Vector3(ratio, ratio, ratio) );
    transform.position = targetPosition + centre.position;
    //calculate planet surface normal
    surfaceNormal = transform.position - centre.position;
    surfaceNormal.Normalize();
    //GameObject's heading
    var headingDeltaAngle = Input.GetAxis("Fire2") * Time.deltaTime * rotationSpeed;
    headingDelta = Quaternion.AngleAxis(headingDeltaAngle, transform.up);
    //align with surface normal
    transform.rotation = Quaternion.FromToRotation( transform.up, surfaceNormal) * transform.rotation;
    //apply heading rotation
    transform.rotation = headingDelta * transform.rotation;
}

Hm. I do not fully understand your description, but what your script actually is doing is to assign the String value "Sphere" to a variable (varplanet) defined in a script(?) called "newgrav" that is attached as a component to an object called "tornadogameobject". Is that correct?

I see no GameObject "Sphere" here, maybe this is the confusion? What are you calling a "target"? Would you like to assign a reference of the GameObject "Sphere" to the variable varplanet? Then you should do:

var sphere = GameObject.Find("Sphere");
transform.Find("tornadogameobject").GetComponent("newgrav").varplanet = sphere;

Hope this helps

Ben

UPDATE

Based on the discussion below in the comments it should be "...planet = sphere" and not varplanet:

The variable planet requires a SphereCollider which hopefully is attached as a component to your planet.

So the assignment should be:

var sphereColl : SphereCollider;
sphereColl = GameObject.Find("Sphere").GetComponent(SphereCollider) as SphereCollider;
transform.Find("tornadogameobject").GetComponent("newgrav").planet = sphereColl;

Ben