How do I get the y coordinate of a terrain at any time?

Hello guys!

I’m trying to make a hack’n’slash type game. I have some issues with my character’s movement script.
I would like to know if i can get the y coordinate (aka the height of the terrain) just under my character so he could stay “fixed” to the ground.
Thank’s in advance =)

You can use the Terrain.SampleHeight function to get the terrain height at a given position. In fact, the sample code there is moving an object’s y to the terrain height.