Enemies fall through floor when chasing player.

I have some scenery models with mesh colliders attached, along with enemies placed ontop of them. In my current AI code for the enemies, they chase the player by moving to the players position value, as described below.

function ChasePlayer()
{
    //print ("Chasing Player");
    animation.CrossFade("Walk", 1);
    dir = target.transform.position  - transform.position;

    dir = dir.normalized;
    transform.Translate(dir * speed * 5 * Time.deltaTime, Space.World);
}

However, when the enemy chases the player up a hill, they walk through the floor ignoring the mesh collider, and fall to their death. Each enemy has a character controller and a platformer controller attached.

The game is a 2D sidescrolling platformer if that helps.

Couple things you could do:

  1. Don't edit the bot's transform position directly, it is likely you're pushing them into the terrain, use velocity or give the bot a proper move script like the player has
  2. Change the bot's collider if it's a mesh collider as they tend to get stuck more easily
  3. Increase the physics calculations per frame to try and catch collider penetrations (this doesn't solve the source of the problem)
  4. Add box colliders to the terrain if you're using mesh colliders for the terrain to "reinforce" them