Creature AI. Child with collider, parent with navmesh agent

I am making a simulation of an environment with creatures roaming about. There are predators and prey. When a predator senses a prey it chases it.

I have acheved this using navmesh, OnTriggerEnter and agent.SetDestination.

Now i want the predator to eat the prey. My idea is to have muliple children with a collider attached, detecting the distance between the two. Like having a ‘sense’ collider and a ‘bite’ collider.

My problem is i dont know how to send the ‘other’ variable from the childs OnTriggerEnter to my parents SetDestination.

This is my code so far

Parents javascript:

#pragma strict

private var agent: NavMeshAgent;
var eaten : int;

function Start () {
	agent = GetComponent.<NavMeshAgent>();
	Invoke("walk", 0.5);

function Update () {


//InvokeRepeating("walk", 0, 5);

function walk () {

	var randomTime = Random.Range(0, 5);

	var randomDirection = transform.position + Random.insideUnitSphere * 20;
	Invoke("walk", randomTime);

function walkTo() {

and the childs ‘sense’ javascript :

#pragma strict

function Start () {


function Update () {


function OnTriggerEnter(other : Collider) {
    var AIname : String;  
    AIname =;
    SendMessageUpwards ("walkTo", AIname);
    print ("hit");

Any help would be appreciated. Is there a better method?

I think you want this
at the top of your script

 var preyDestination : Vector3;

then in the trigger function

 OnTriggerEnter(other: Collider)
  preyDestination = other.gameObject.transform.position;

then you would grab the preyDestination value in your first script, or send it to it in the second script. I have no idea how referencing other scripts works in javascript to be honest