creating a checkpoint system

Hello… I’m a noob, please be gentle.

I have a car, with a set of colliders in it (because the car isn’t a uniform shape) - these colliders are called “body1” to “body4”

now, i want to have a variable in the car which is “checkpoint” location, when the car passes through a trigger box, the trigger box passes it’s position data to the car and populates the cars “checkpoint” location…

the only problem is i can’t access variables in the main cars script…

checkpoint boxes script… sends a “checkpoint” message to the car…

function OnTriggerEnter (other : Collider) {
	other.gameObject.SendMessage ("checkpoint", SendMessageOptions.DontRequireReceiver);
}

But unfortunately, it sends it to the colliders… not the parent object… (so if I create a function “checkpoint” and put it in the body1 collider it works, (but then I don’t know how to pass this data to the parent script))

i really want to do this:

other.gameObject.parent.SendMessage - but that causes an error…

If you read the error you’ll see that parent is a transform and doesn’t have a SendMessage function, and that gameObject doesn’t even have a parent member to begin with (Transform does).

Try -

if ( other.transform.parent )
other.transform.parent.gameObject.SendMessage( blah );

In the future, remember that it’s usually incredibly hard to debug code if there’s an error and we don’t know what it is. Always post the error and the line that’s causing it.

Thanks vicenti, the error was just some rubbish that didn’t help me really… but note taken…

I finally fixed this by using “SendMessageUpwards”