Unity with Bullet Physics : Mesh Collision - unity3d

I am trying to use Mesh Collision with a cube with hole model that created from Blender and export it to .fdx then import to my Unity project
Following this doc. http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Shapes
I am using bConvexHull for this object.
I drag the mesh into the field and press Build Mess. No error.
And set BRigitBody to make it stay still.
After that i create a small red cube on top of the first object. And set BRigitBody to make it fall down to the first object.
After hit Play button, The red cube should fall down into the hole of the first object.
But it just stay on top like this
What i have missed or did it wrong?
Please give me some explanation.
Thanks.

A convex collider, by its definition, cannot have holes.
Use btBvhTriangleMeshShape instead.

Related

How can I remove small part of collider of game object in unity 2d

click here for gif show of what I want
I want to remove mesh of object when user click on object and also remove its collider to make another object fall from that removed mesh area...
I am using unity since last month so I don't have much experience and knowledge, please help me...
Creating the destructable ground particles
One way to achieve whats shown in the gif is by creating a prefab of e.g. a circle collider that is instantiated in the area of where the dirt is in your gif. It acts as a "ground particle" and keeps the objects above itself.
You instantiate a lot of them in the area so it acts as a big collider although it is actually a whole array of smaller colliders.
Implementing the interaction logic and deactivating the ground particles
Ater that you implement the functionality of dragging the mouse over the ground particles, removing them. That is also not difficult. Shoot raycasts into the screen at the postition of the mouse (remember to use Camera.ScreenToWorldPoint) and get the collision information (confer to https://docs.unity3d.com/ScriptReference/Collider2D.Raycast.html). With the collision information you can get the reference to the instance of your ground particle(raycasthit.other.gameobject) which is then disabled through script(gameobject.setActive(false)).

Player falls halfway throufh the floor till the outer edge of collider. instead of the inner edge

As you can see in the included video the player falls over the floortile till the outer edge of the floor. Instead it should stop at the inner edge of the tile so it looks like its standing ontop of the tile. Can anyone help? I cant find anything on the internet regarding my issue.
Im sorry if this is a easy fix. Im a beginner. This for a school project :)
Video: https://streamable.com/99jz2o
enter image description here
Photo of sprite standing on the wrong edge of the tile.
Edit: I went back to the tile palette and redrew the level. This time selecting the game object + bitmap again. Now it works. Probably the reason why it didn't work was that when I drew the level I had not added Tilemap Collider 2D and Composite Collider 2D. Now redrawing with those 2 components added it works as it should!
The problem is with your tile map collider. Instead of using this, set empty game objects as children of the objects that make up the . Then, add BoxCollider2Ds to each one, and add scale them to fit the map. If that doesn’t work, then it is either a problem with the rigidbody, or the box collider, make sure that all of the settings are set to default, then slowly change them back, and you will discover what is causing the problem. Then you can comment on this post what variable changed it.
Your issue is the Composite Collider. The docs specify that they
do not define an inherent shape. Instead, it merges the shapes of any
Box Collider 2D or Polygon Collider 2D that you set it up to use
When you attach a BoxCollider2D or PolygonCollider2D, there is a check box on them that specifies Used by Composite. When checking this box, other fields will disappear as they are now controlled by the CompositeCollider.
To use this collider, make a new object that will hold all your other colliders or make a few that hold sections of your map. Give this new parent object a CompositeCollider2D and give all the children BoxCollider2D or PolygonCollider2D. After this, make sure to check the box Used by Composite on the children Colliders.
Edit: Sorry just saw you were using a Tilemap. Just make the CompositeCollider a parent of your Tilemap while keeping the Used by Composite checked.
Edit 2: I am not too familiar with Tilemaps with Composite Colliders, but one other solution you can try before re-childing is changing the Geometry Type field on your CompositeCollider from Polygons to Outlines.

Collider for blender pot model inside Unity

i've made a simple pot model inside blender:
So the idea is that after importing to unity, generating mesh collider, adding ridgin body i would like to be able to put smothing inside the pot. Now it's generating collider but without a "hole" inside, so if i throw smth inside it just bounce off the top. Is there any way to do it simple way? I'd like to avoid making a collider by hand in unity, using cubes and so...
Image overview:
Your collider needs to be concave
It isn't clear from your question how you're "generating mesh collider," but the results are clearly generating a convex collider.
That said, some things to know about mesh colliders (and concave ones even more so): They are very compultationally heavy to calculate, so they should never...
move
scale (especially non-uniformly)
rotate
...at runtime.
Alternatively you can use multiple box colliders in the same orientations as the side-segments of your can (along with one or two for the bottom, depending on how small of an object you'll be dropping inside).
Uncheck the generate collider box from the import settings, add a mesh collider component and check convex.
I would use four or six box colliders for the walls of the pot and another for the floor. You can scale each box collider along each axis, but if you want to rotate a box collider you will need to give it a parent and rotate the parent. Box colliders are very low cost for the physics engine compared to mesh colliders.

Blender to Unity: Add Custom Collider to A Low Poly Style Terrain

I have created a low poly terrain object from Blender using a Plane, displaced and decimated it. I then exported it to Unity as an FBX object. As what I expected, my player simply falls through it since it has no colliders on. I could place a Box Collider on the object, but seeing it is a low poly style terrain with lots of bumps, it'll be pretty awkward to have my player walk straightly even if the ground is slightly raised. Even so, there are mountain areas in my terrain object and box colliders would totally be out of the question.
I was thinking of using the Mesh Collider in Unity. I tried experimenting with it but failed. There are also no clear tutorials online on the said situation. How can I add a custom collider to this terrain so the player can walk to it, plus without using the hastly Box Collider.
Here is my terrain object in Blender:
As you can see, putting a box collider is totally impossible.
You can make individual Sphere, Capsule and Box Colliders, hide their Mesh Renderers and then rotate, scale and place them to make something similar to your mesh. However, Mesh Colliders should be your best option, after adding a mesh collider to your mesh, make sure the convex option is NOT checked and also make sure to select the same mesh that the GameObject is using from the Mesh field in the Mesh Collider component.
Alternatively, if you want your collider to be simpler than your actual mesh, you could make a simpler mesh (either with an external program or by downloading the ProBuilder package in Unity), overlay that mesh with the terrain you have, give it a Mesh Collider and then hide its Mesh Renderer component.
I don't exactly understand what you meant by "I tried experimenting with it but failed." Did your character keep falling through? Did the character get stuck? Was the mesh collider generated in an incorrect way? I would be able to help you better if you can give me a detailed explanation.

Microsoft HoloLens Tutorial, cursor on own object

I'm starting to develop for the Microsoft HoloLens. For that, I made the Tutorials from the Hololens Academy. This worked fine.
Now I want to use a simple 3D Sphere instead the astroman and add the cursor from the academy source code. My problem is that the cursor is not visible while its on the sphere. Sometimes I can see the cursor at the border of the sphere.
If the cursor is not pointing on the sphere, its visible. Like in the tutorial its a star then.
Steps to Reproduce:
Follow the tutorial Holograms 210 Chapter One. In step "Setup the scene" Don't add AstroMan, SpaceAudioSource and SpaceBackground. In hierarchy click Create --> 3D Object --> Sphere. Then place the sphere in front of the camera X: 0, Y0, Z3. And scale it to X=Y=Z=0.2. Then follow the tutorial chapter 1 to the end.
What do I wrong? I tried to add Material, select the Trigger checkbox... It's not working.
Thanks a lot for every kind of help.
Cursor not centered on sphere:
Cursor centered on sphere:
SOLUTION
Thanks to the answer from #Cameron Vetter I found my mistake.
My collider was exactly the same size like the mesh render. So the cursor and the mesh where exactly on the same height. Thats why I could not see the cursor on the object.
I removed the standard collider and added a box collider. Then I scaled this box collider a bit greater than the mesh (1.05) each axis. Now it works!
The cursor uses the unity collider to determine if it hits an object by raycasting from the viewer's perspective out and seeing if it hits any colliders. My guess is that you did not add a collider to your sphere.
In unity select your sphere in the hierarchy and click add component in the inspector. Add a Mesh Collider and everything should just work.
In real world use cases you would want to use a sphere collider instead of a mesh collider. They are less processor intensive but will require you to setup the center and radius properly.