Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Sphere collider hopping on flat terrain

Discussion in 'Scripting' started by besuser, Dec 12, 2007.

  1. besuser

    besuser

    Joined:
    Oct 9, 2007
    Posts:
    292

    Any idea why this might be happening? The terrain is completely flat. A friend suggested that maybe the collider was detecting seams in the terrain mesh. The trail you see is the standard trailrenderer. The only thing my code does to affect the ball is to initially set the velocity in the z direction on a button press.

    Any help is greatly appreciated!
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,400
    Does the collider have "smooth sphere collisions" checked?

    --Eric
     
  3. besuser

    besuser

    Joined:
    Oct 9, 2007
    Posts:
    292
    Unless I'm missing something, Terrain Colliders don't have the "Smooth Sphere collision" option. Mesh Colliders do, but if I replace the the terrain collider with a mesh collider, I don't know how to set the mesh value in the mesh collider (since we don't have access to the terrain mesh, as far as I know). So I guess the question count is up to 3:

    1) Why does the ball hop on a flat terrain collider?
    2) If I apply a mesh collider to a terrain, is there a way to set the Mesh value?
    3) If I replace or remove a terrain collider, is there a way to reapply it to the terrain? (i.e. there is no "terrain collider" under the Component->Physics menu)

    Thanks so much for the help as always!
     
  4. Brian-Kehrer

    Brian-Kehrer

    Joined:
    Nov 7, 2006
    Posts:
    411
    Bump.

    I have this issue as well, and it never really was fully resolved--although, I never produced such a clear example.

    This is a terrain specific bug, a similarly shaped mesh will not incur this error.

    However, sometimes I can pass through a mesh collider, whereas on the terrain collider if this occurs, Unity compensates. My guess is what is happening is the object is 'falling' through the terrain, and the terrain engine is compensating by pushing it back up- resulting in the bump you see.
     
  5. drJones

    drJones

    Joined:
    Oct 19, 2005
    Posts:
    1,351
    if that's the case would increasing the physics timestep help any?
     
  6. Brian-Kehrer

    Brian-Kehrer

    Joined:
    Nov 7, 2006
    Posts:
    411
    Likely, yes, it would. Unfortunately in my case, I'd need an impossibly short time-step to remove it entirely.

    Really it would be nice if there were some built in way to damp that, or fix it. Everything I've thought of is too math heavy. Did you report this project to OTEE as a bug?

    Also, is it rolling over a vertex when it hops?
     
  7. besuser

    besuser

    Joined:
    Oct 9, 2007
    Posts:
    292
    I don't think I reported it (don't remember frankly =).

    I don't know how to test if the ball is hitting a seam in the terrain mesh (the built in terrain system, not our own mesh), since there is no way that I know to view the mesh. I was fooled at first when looking at the terrain- I thought I could tell where the seams were and then my buddy reminded me that I was only looking at the texture, and I don't think there is any correlation between polygons and texture tiling.

    Can I trouble anyone from the unity team to offer insight on how to avoid the dreaded bump?
    Also, any insight into my other questions:
    1) Is the terrain mesh accessible in any way? (Code, Unity GUI, anything?)
    2) If I replace a terrain collider with another collider, is there a way to restore the terrain collider?
     
  8. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    besuser, Does this happen with every fresh scene? The reason why I ask is that during beta testing of unity 2, something came up where the terrain mesh collider was not updating when the terrain was. I'm positive this was fixed during the beta, but maybe its an old terrain collider thats invisible?

    Unlikely, but I thought I'd ask
    AC
     
  9. besuser

    besuser

    Joined:
    Oct 9, 2007
    Posts:
    292
    I have tested this on a number of new projects, however, I'm still @ unity 2.0, so if this is something fixed in the recent patches, that would be awesome!

    Unity guys, any insight, in addition to my questions above?

    Forgive me for being bothersome!
     
  10. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I don't know if this is possible with a terrain, but have you tried adding/changing the physics material? Probably not a solution as much as a workaround if it fixes it...
     
  11. Elharter

    Elharter

    Joined:
    Sep 20, 2015
    Posts:
    58
    i want to dig this post up again....ive got exatly the same problem with sphere collider on terrain (collider). The sphere is hoping around if the hmap resolution is higher then 65x65........ the interesting part is, that the behaviour is changing if the car is driving horizontaly or vertically....

    Did someone got a solution for this?

    thanks