- Home /
Terrain Collider Bug in Unity 5
Hi,
Terrain collider is not working right. Take a look at this;
Car will go through hill. Hill's collider is at wrong place on terrain;
Car is at top of the hill collider at this image. So anyone got this issue?
Was having this problem too. Any changes to the mesh didn't update the terrain collider until either:
a) the scene was saved b) Unity was restarted c) I created a build of the project
i dnt think so after we change the width and length of terrain after creat mountain the terrain mountain colider is not working coz terrain colider is move out when we are change the setting of width and lenth of terrain .... we should in start terrain modifie the width and length then creat mountain ...
Answer by FuryOfFlames · Mar 04, 2015 at 04:56 PM
Been having the same problem. Looks like the engine has trouble making mesh colliders for terrain after you change geometry. Probably has to be patched out.
Update: Seems to get fixed after you save your scene.
Thanks for the update/workaround. I thought I was loosing my $$anonymous$$d.
Joined the forum just to say thank you
so....thank you
Thanks! I had the same problem with my character movement script after editing the terrain to create a path through a mountain area. Completely fixed after saving, appreciate the advice.
my character pass under the terrain and after save the scene it's work weel, thank you :D
Just experienced this problem, the collider seems to have some kind of offset. Saving the scene and restarting Unity didn't help. Do you guys have any info on this? (I'm generating the terrain at runtime)
Answer by LesterZw · Apr 07, 2015 at 06:26 PM
If your modifying terrain in playmode try this workaround,
float[,] terrainHeights=terrain.terrainData.GetHeights (0,0,terrain.terrainData.heightmapWidth, terrain.terrainData.heightmapHeight);
terrain.terrainData.SetHeights (0,0, terrainHeights);
Make sure this executes after the code that makes the modifications to the terrain.
yes, and depending if you already have the float terrainHeights (or whatever you have called it) already at the top of the script then all you have to do is enter the code after the "=" additionally if you made a change for terrain that changes the name at the top of your script you will need to change the terrain part of each of the terrain.terrainData to what you have made. for example in $$anonymous$$e at the top i have public Terrain myTerrain (this allows me to drag my terrain in the inspector so if i change the terrains name it will still work) so where it is terrain.terrainData $$anonymous$$e now says myTerrain.terrainData
Setting the heights in the terrainData doesn't update e terrain collider. Still in 2017.4
Answer by bugra271 · Mar 05, 2015 at 03:23 AM
Restarting Unity may fix the problem sometimes.
For example im making terrain in playmode and i take terraindata from existing terrain, i cant restart unity or save scene or something because in my playmode i can modify terrain. I have also this problem.
Answer by Jubtog · Aug 11, 2015 at 04:24 PM
For anyone not editing in play mode and still having Terrain Collider issues that aren't fixed with a save...
I don't know if it's a good solution, but I fixed this by baking a nav mesh into all my scenes. I then added a nav mesh agents to the player as well as all my enemy characters. It works better than nothing, but you have to re-bake if you change anything static in the scene, and baking can take a long time.
If there is a better fix in another thread please post a link in this thread.
Your answer
Follow this Question
Related Questions
Terrain Tag OnControllerColliderHit not showing 0 Answers
first person controller help 1 Answer
How to create a ground/terrain/floor that won't respond to gravity or objects falling on it? 1 Answer
How can a character not move out of box collider's bounds? 1 Answer
Solution for the FPS Character Controller falling through terrain 2018.3 Version 0 Answers