How to keep a moving object at the height of the terrain? (script)

Hey guys! I hope anybody can help me with my problem. (Im currently using unity 4 Pro)

I need a script that attaches a abject to the height of a terrain. So that, if the object moves still keeps at the height of the terrain under it, if the terrain gets higher or lower.

Can anybody help me with that script?

Look into the Terrain.SampleHeight() function.

You could cast a raycast down, then set that hit height y for your character position. If your character pivot is not base 0,0 then simply add height offset to that cast height.