- Home /
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
removing the terrain collider and then reapplying it : No Sucess
Checked isTrigger property on all the terrains : It's unchecked
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.
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
All I can suggest is make some custom editor tools to read the terrain data of the old terrain, then apply it to the new 4.x terrain.
Basically I'm saying read the terrain data on the old terrain, then apply that data to the new terrain, then delete the old terrain.
This of course will only work if the 4.x terrain works with the same height/splat/detail information as 3.x . But if it does work, then all heights, textures, trees and grass will be the same as the original terrain.
I don't have 4.x, but if you are stuck or don't know how to read the terrain data then i shall write you a script to test my theory.
Good question, upvoted in the hope that someone with experience with 4.x will see this and help.
it would be great if you could provide me a script for this ...
Answer by AlucardJay · Apr 30, 2013 at 04:47 AM
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...
Your answer
Follow this Question
Related Questions
Sphere Collider with Terrain 0 Answers
Capsule collider going through terrain collider 1 Answer
Player falling through Terrain collider 0 Answers
Terrain rotating on collision,Terrain rotates on collision 0 Answers
Terrain Generation ruins collision 1 Answer