Getting a Trigger's parent

I have few planet spheres, with a big trigger called the Atmosphere as its child in each of them.

Players can hover around the space for unaffected by the planet’s gravity unless they enter a “targetPlanet”.

I wanted players that enters the Atmosphere trigger to consider the parent planet as their “targetPlanet”.

I tried doing this, but the “targetPlanet” variable did not change at all, even though there is no errors.

   function OnTriggerEnter (other : Collider) {
    	if (other.tag == "Player") {
    		motionCon = other.GetComponent("Planetary_Jumper");
    		motionCon.targetPlanet = transform.parent;
    	}
    }

Helps?

Considering this hierarchy :

PlayerObject [TransformObject]

  • Collider (Script)
  • Planetary_Jumper (Script)

PlanetObject [TransformPlanet]

  • Collider (Script)
  • Script with
    OnTriggerEnter

When they collide, You can set the PlanetaryJumper target property with the following script in [Script with OnTriggerEnter] :

function OnTriggerEnter (other : Collider) {
        if (other.tag == "Player") {
           motionCon = other.gameObject.GetComponent("Planetary_Jumper");
           motionCon.targetPlanet = transform;
        }
    }