Crawling around the terrain

Hello, I am a Unity newbie. I have a bug model that crawls around randomly on the X/Z plane, using transform.Translate. I also have a terrain which I have set as a Mesh Collider.

What I want is for the bug to crawl around on the terrain, setting his orientation to match the polygons he's crawling on. However, I'm having difficulty doing this with just the default collision functions.

How can I determine the Z position of the terrain below my bug model? Can I get the orientation of this point, so I can use it as my model's "up" vector?

I found a reasonable answer to my problem. I used raycasting to find the proper Y coordinate, then used the normal to set orientation. I still wish I had a better handle on collision detection, but that's for another day I suppose...

    var hit : RaycastHit;
if(Physics.Raycast(transform.position+Vector3(0,10,0),Vector3(0,-1,0), hit, 20))
    transform.position.y = hit.point.y;
    groundNormal = hit.normal;

Here, this code should do the trick:

function OnCollisionEnter(collision : Collision) {
    var contact = collision.contacts[0];
    var rot = Quaternion.FromToRotation(Vector3.up, contact.normal);
    transform.rotation = rot;

It ensures that your bug's Y will be the same as the Y of the last thing it touched.

If you’re using a CharacterController you need to hook into the OnControllerColliderHit. Here’s some C#:

using UnityEngine;
using System.Collections;

public class FollowTerrain : MonoBehaviour
	public TerrainCollider terrainCollider;
	public void OnControllerColliderHit(ControllerColliderHit hit) {
		if (hit.collider == terrainCollider) {		
		    var rot = Quaternion.FromToRotation(Vector3.up, hit.normal);
		    transform.rotation = rot;