Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by Zart · Aug 30, 2014 at 06:38 PM · meshmeshcolliderdynamic mesh

Partial meshcollider failure. Why does this happen?

I'm trying to generate terrain dynamically in my game. While doing this I encountered the 65000 vertex limit, so in order to work around this I have made a prefab and just instantiated the amount of meshes I need in order to cover my terrain.

the mesh algorithm looks like this:

 visualMesh = new Mesh();
 visualMesh.vertices = verts.ToArray();
 visualMesh.uv = uvs.ToArray();
 visualMesh.triangles = tris.ToArray();
 visualMesh.RecalculateBounds();
 visualMesh.RecalculateNormals();

 meshFilter.mesh = visualMesh;
 meshCollider.sharedMesh = visualMesh;

In 95% of the cases this works perfectly but sometimes when i change the size of a triangle or make a small change in the procedure to add triangles to this mesh, approximately half of the mesh looses its collision detection and players and other objects just fall through the terrain. The annoying part is that i don't know why. When i change the size of the triangles in one part of the mesh, the collision failure happens in an entirely different part of the mesh.

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by AlwaysSunny · Aug 31, 2014 at 01:00 AM

Other problems may exist that I can't see here, but I recall that colliders are finicky when you mess with them at runtime. IIRC, disabling / re-enabling them (even in the same frame) fixes certain issues like this.

Comment
Add comment · 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
0

Answer by Zart · Sep 01, 2014 at 10:56 AM

I tried fixing it by looping through the meshes and disabling/enabling them on every update but it didn't work.

the code looked like this:

 void Update()
 {
     for(int i=0; i < meshes.Count; i++)
     {
         meshes[i].enabled = false;
         meshes[i].enabled = true;
     }
 }

what other information do you need in order to figure out whats wrong with it?

Comment
Add comment · 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 AlwaysSunny · Sep 01, 2014 at 07:41 PM 0
Share

Sorry for being unclear; I meant disable/re-enable the mesh collider component after having performed changes to the mesh which it uses. To my understanding, this "refreshes" the collider and updates it within the physics simulation.

Also it's possible the error could exist in the mesh generation code? Sometimes inconsistent collision on a mesh has something to do with improper normals, but generally such errors are visually apparent.

avatar image Zart · Sep 02, 2014 at 10:28 PM 0
Share

Is there a way of debugging for improper normals? $$anonymous$$y meshes are quite large and has some small triangles, so they may be hard to spot. If there is a triangle configuration that causes this I might be able to write my own debugging code.

$$anonymous$$y meshes are only created once right now but they will be dynamic later. I intend to create smaller meshes and re-rend the particular mesh that needs changing.

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Non-Convex Mesh Collider triangle limit - is it more than 255? 0 Answers

Changing Mesh and Mesh Collider of an Object 0 Answers

Find all triangles inside given bounds 1 Answer

Weird bounce on collision with perfectly aligned (generated) meshes for fast object 3 Answers

Merging meshes at runtime - upside down normals? 0 Answers


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