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 ikelaiah · Jul 22, 2014 at 11:27 PM · physicsrigidbodyfalling-through-floorfalling-through-terrain

Is it possible to make a Mesh Collider thicker?

I'm having problem of moving rigidbody objects going through mesh terrain, even with '`Continous Collision Detection`' is enabled. A good solution proposed here is to make the ground collider thicker.

Now, since I am using a mesh collider for the ground, is there a way to make the mesh collider thicker?

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
1
Best Answer

Answer by WilliamLeu · Jul 23, 2014 at 01:01 AM

One way is to make a new mesh using the old mesh. Here's an example that uses the normal for each vertex, although it's far from perfect - mostly because the higher the perturbation, the smoother the mesh will get, and it doesn't handle seams to smoothing groups well. But, it's not a bad starting point.

 using UnityEngine;
 using System.Collections;
 
 public class Test : MonoBehaviour {
 
     void Awake()
     {
         MeshCollider mc = GetComponent<MeshCollider>();
         mc.sharedMesh = ThickerMeshUsingNormals( mc.sharedMesh, 1.0f );
     }
     // Function only cares about verts, tris and normals...
     // Which should be fine because we're only messing with
     // this stuff for collision
     Mesh ThickerMeshUsingNormals( Mesh m, float fPerturb )
     {
         // USE THE NORMALS TO INFLATE THE MESH
         // We're going to store the new results as a new
         // verts list.
         Vector3 [] rv3OrigVerts = m.vertices;
         Vector3 [] rv3Norms = m.normals;
 
         int nVertCt = rv3OrigVerts.Length;
         Vector3 [] rv3NewVerts = new Vector3[ nVertCt ];
         for( int i = 0; i < nVertCt; ++i )
             rv3NewVerts[i] = rv3OrigVerts[i] + rv3Norms[i] * fPerturb;
 
         // CREATE AND RETURN THE MESH
         Mesh mRet = new Mesh();
         mRet.vertices = rv3NewVerts;
         mRet.triangles = m.triangles;
         // A cheap thing to do would be to just transfer the
         // old normals, although that wouldn't be right (both
         // in spirit, and mathematically).
         //
         // mRet.normals = rv3Norms;
         mRet.RecalculateNormals();
 
         return mRet;
     }
 
 }
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 ikelaiah · Jul 23, 2014 at 01:12 AM 0
Share

$$anonymous$$aking a mesh collider by using vertex's normal? That is smart. But I got your point. The higher the perturbation, the smoother it gets. I suppose it is like inflating a balloon.

avatar image ikelaiah · Jul 27, 2014 at 11:26 PM 0
Share

Accepted your answer, since you provided an approach on how to make mesh collider thicker (Inflating). A good starting point.

avatar image
0

Answer by markedagain · Jul 23, 2014 at 12:26 AM

how fast is the object moving to the ground ? and have u changed or altered game time in anyway ? is it anywhere on the ground or some areas where there is deformation ? also have u tried DontGoThroughThings

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 ikelaiah · Jul 23, 2014 at 12:34 AM 0
Share

@markedagain How fast the objects move? Free fall by the gravity. Have I changed the game time? Nope. $$anonymous$$y terrain has a lot of deformation, and occasionally falls through it.

I tried that script at skin 1.0 and objects still penetrates, however, at lesser frequency than before.

avatar image markedagain · Jul 23, 2014 at 01:04 AM 1
Share

if the issue happens in certain areas can u not simply put some small box colliers near ground level to fortify that gap ? not really a solution , and i dont have much more since i work very little with mesh colliders

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

24 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

Related Questions

THIN objects can fall through the ground? (AMAZING SOLUTION) 2 Answers

My object falls through terrain. 8 Answers

Rigidbody object falling through floor. 8 Answers

Character with box collider sticks to walls 0 Answers

Throwing knife doesn't throw correctly 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