Tiled terrain

Hi, all!

In my new game I have a terrain that is made up of different tiles, because some of them are to be replaced with prefabs (assets) of the required size. I want to check at all times that my First Person Controller remains above the terrain, using the well-known

transform.position.y = Terrain.activeTerrain.SampleHeight(transform.position) + Terrain.activeTerrain.transform.position.y;

Problem: when I leave the original tile for an adjacent one, SampleHeight no longer works correctly ; it looks as if the heightmap information has been lost or is not updated properly.

Any ideas ?

Thanks in advance,
Thierry

Set the terrain explicitly instead of using activeTerrain.

–Eric

Thanks, Eric.
I can certainly write a function which, given the FPC’s position, will return the name of the terrain GameObject that lies under.
Now, for my call to SampleHeight, can I keep the FPC’s absolute position or do I have to make it relative to the new terrain’s origin?
Thierry