unity 4.0 terrain collider issue

HI All,

I just ported my game form unity 3.5.7 to unity 4.1.2, but i am observing some weird behaviours in the game after porting.

The issue which is concerning me the most is terrain colliders, they doesn’t seem to work. The players always go through the terrain .

I have tried a lot of things already like

  1. removing the terrain collider and then reapplying it : No Sucess
  2. Checked isTrigger property on all the terrains : It’s unchecked
  3. Put a new terrain above the current one : It’s working with the newly created terrain but i want to use my old terrain as i have already done lot of work on it already.
  4. Try using other object like a cube : it worked but still i want to use my old terrain

so after trying all the points listed above, its certain that it is not a problem with character(as it is working absolutely fine with other objects)there is surely something wrong with the terrain colliders.

Can anyone please help me out with this, thanks in advance

it would be great if you could provide me a script for this ...

1 Answer

1

I don’t have Unity 4.x to test this, but this is tested and working in 3.5 . Create a new scene. Create an empty gameObject, add this script to it. Then drag your old terrain and new terrain into the scene, and from the scene drag them into their inspector slots. Then Right click on the inspector where it says ScriptName (script). There is a drop down that normally says :

Reset
Remove Component
Edit Script

now there should be another one

Read Terrain Data

click on that. The new terrain should now be the same as the old terrain. All the textures, trees and detail should be added to the new terrain also.

WARNING this edits the terrain and cannot be undone.

BACKUP your terrain , right-click your terrain and then select Export.

#pragma strict

var oldTerrain : Terrain;
var newTerrain : Terrain;

private var oldTerrainData : TerrainData;

#if UNITY_EDITOR

@ContextMenu( "Read Terrain Data" )

function ReadTerrainData() 
{
	if ( !oldTerrain || !newTerrain )
	{
		Debug.Log( "No Terrain in the Inspector" );
	}
	else
	{
		oldTerrainData = oldTerrain.terrainData;
		
		newTerrain.terrainData = oldTerrainData;
	}
}

#endif

If it doesn't work in Unity 4.x, I'll delete the answer. Hope it does.

thanks a lot mate, i will update you on the progress...