• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Cains · Jan 10, 2020 at 06:55 PM · collisionphysicsterrainterraincollider

Terrain collider is inaccurate

I have a terrain with a terrain collider and when I walked around on it I noticed that the collisions seemed inaccurate but almost correct, so I looked at the collision geometry with the physics debugger and found this (collision geometry is in green):

alt text

As you can see, it's mostly correct but very inaccurate in many places on slopes. Is something wrong or is there a setting to control this? What's weird is that it looks like the collision geometry has faces that can perfectly match the rendered geometry, it just doesn't. This kind of accuracy is definitely unacceptable as characters clip into and float above slopes.


Edit

To be clear, this is definitely not z-fighting in the physics debugger's display as I found this by my character floating and clipping through terrain hills. It's hard to show in a screenshot, but if you zoom in you can see clear differences between the rendered gray faces and the collider's green faces. I've whipped up a very simple project to show this and I'm surprised no one else is seeing this as it's incredibly simple to reproduce. In this project I just have a terrain with hills, a character controller with a simple movement/camera script, and a couple pins in the land that show obvious points of floating or clipping. You can also look at the areas of these pins with the physics debugger and see it is because of the difference between the terrain collider's faces and the rendered faces. I made this from scratch in a few minutes using only built-in Unity assets and I'm using Unity 2019.3.0f3. It's also here.

terraintest.zip (25.6 kB)
Comment

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image

Answer by lgarczyn · Jan 12, 2020 at 01:40 AM

This looks like z-fighting, which would just be a rendering issue. The height difference looks too small to affect your rigidbodies in a meaningful way. To get more help please provide a picture of a character clipping or floating, as well as the movement script.

Comment
Bunny83

People who like this

1 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Cains · Jan 12, 2020 at 09:44 PM 0
Share

I can see it looking like that but it's definitely not z-fighting, if you actually zoom in on the editor you can see that almost all of the artifacts in the screenshot are actual height differences in the faces that cause very noticeable clipping and floating. I added an example project to clearly show it using very simple base assets.

avatar image

Answer by Bunny83 · Jan 12, 2020 at 02:13 AM

Unity uses PhysX for 3D physics.PhysX has different collider types and Unity's colliders pretty much map one to one to the physX types. The Terrain collider is not a mesh collider but a height field. The height field has some features we can not control with Unity, like the tesselation flags for example. Though like ceandros said I don't see any issue in your image beside the possible z-fighting. So it's not really clear what your question or concrete issue is.

Comment
lgarczyn

People who like this

1 Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Cains · Jan 12, 2020 at 09:51 PM 0
Share

This is why I'm confused as the physics debugger seems to show that the collider's faces are controlled by a height map of the same resolution as the rendered faces, they are just simply off in their height values. I added a project to clearly show what I'm talking about, but my issue is simply that the terrain collider's height values do not match the rendered height values in all locations as shown in the physics debugger. There are no options on the terrain collider component so I'm not sure what to do about it just being wrong in places.

avatar image wireframer Cains · Jan 20, 2020 at 06:52 PM 1
Share

This seems to be caused by the PhysX heightfield being triangulated in the opposite way to the terrain mesh (see screenshot from your example file), so Bunny's probably right that it has to do with the tessellation flag. What I find bizarre is that this seems like it'd be a frequently reported issue, but I went as far back as Unity 2017 LTS and it's also present there, yet this is apparently the only time it has been reported. The bigger the height difference and the larger the distance between heightfield samples the more visible the error is. With only two ways to do it, it seems like it'd be a trivial fix. If there is no way to change the PhysX triangulation, as Bunny says, and no way to change it on the Unity terrain side either (I'm guessing that's the case), would it be worth filing an issue on the issue tracker? Edit: I went ahead and reported it as a bug, hopefully it's not some weird limitation and that gets things moving. Edit 2: This has been fixed in 2019.3.0f5/2020.1.0.a19. At the time I tested a18 was the most recent version so it was still present. Triangulation issue

issue.jpg (94.1 kB)
avatar image

Answer by ICE-jdeacutis · Jun 10, 2021 at 10:30 AM

Technically you may be able to solve this using a custom terrain shader. If the size of the quads can be determined, the triangle vertices and UV's could be flipped. Not exactly trivial though.

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

178 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Car falls through terrain 2 Answers

Collision Colliders - Box or Mesh for Terrain 1 Answer

Innacurate terrain collision with fast rigidbody 1 Answer

Physics Materials on SpeedTree? 0 Answers

Terrain Generation ruins collision 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges