public void HandlePredator( string source, StatePatternCritter predator )
{
if ( critter.gameObject.CompareTag("Herbivore") ) // Are we a Herbivore?
{
foreach ( int predatorID in critter.predatorList )
{
// Debug.Log( "\tMatch? " + predator.ID.ToString() );
if ( predator.ID == predatorID )
{
// Debug.Log( source + " WS " + critter.ID.ToString() + " RUUUUUNN!!! " + predator.ID.ToString() );
direction = (predator.transform.position - critter.transform.position).normalized;
direction += critter.transform.position * fleeingDistance;
// Sample the provided Mesh Area and get the nearest point
NavMesh.SamplePosition( direction, out hit, Random.Range( 0f, critter.maxWalkDistance), MeshArea );
critter.navMeshAgent.SetDestination( hit.position );
ToFlightState(predator);
}
}
}
}