I'm trying to import models from blender to Unity, but the mesh colliders are wrong when they are adding them to an object in Unity.
Here are my steps:
Imported new asset.
Checked "Generate colliders".
Added mesh collider and the result is:
Don't generate the collider when you import the mesh, uncheck the box.
You can later add in the inspector a mesh collider component and set it to convex, but this would be the same result you already have. You can uncheck convex, then unity tries to use your current geometry. But if the vertex count is to hight, unity won't apply a collider because the physic system only supports a certain amount of geometry.
enter image description here
you can also duplicate your object in blender and add a decimate modifier and play around with the Ratio or create your own geometry around your object with vertex snapping or any workflow you like, just keep the collider geometry as simple as possible.
Then you can set that mesh in the mesh collider component as mesh source and have a nice and proper collider.
Related
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.
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.
I've set up a Physics Raycast Event System for the Google Cardboard in Unity, which works if I use a cube or any of the pre-set 3D objects. When I import my own object from 3DS Max, however, the Raycast doesn't seem to detect the object. I've checked, my object does have a collider on it, and the layer is set at default. I'm using the GVR API, and the GVR Reticle Pointer.
The problem is that the Collider is not even aligned on that imported Object. The center value of the Collider should be 0,0,0 so reset that. After that, click the "Edit Collider" button, go to the Scene View and modify the Collider until it matches the shape/size of your imported 3D model.
See the image I am talking about below for more info:
I have some models created in makehuman and edited in blender. I export them in fbx and import into unity, but when i put "generate collider" it doen't do anything. I find a solution in adding to a model new collider (capsule for example), but it seems to me that it is really a wrong way to do it
When you use Generate Collider you are actually creating a mesh collider.
When you enable Generate Colliders in the Import Settings, a Mesh
collider is automatically added when the mesh is added to the Scene.
It will be considered solid as far as the physics system is concerned.
Colliders information.
This means that now you have a collider which takes the form of the mesh and you can either re-add the model to the scene so that it contains this mesh collider or you can add it via the Components tab.
You also need to make sure that your new mesh collider can actually collide against other objects. Check what you need to make collisions happen via this table:
Also it is important to note that using primitives instead of mesh colliders is often preferable due to its performance advantages. An example below on how to avoid using mesh colliders:
What is the proper way of creating 2D Mesh with collider?
All I want to do is create some shapes (not very simple like triangle or rectangle) like slide or rounded rectangle. And I want to define a repeating pattern inside it to fill and reduce memory. Lastly I will need a collider around my shape.
Create the entire thing in a modeling program like Blender... same as you would for a 3D model, but all of your shapes/meshes will be flat. Create your textures the same also... all in your modeling program. Then save your file (.blend for Blender) to your Unity assets folder. Now switch back to Unity and drag/drop the prefab that is created form the .blend file on to your scene. Change the renderer if you want (I use Mobile Unlit, or Unlit Transparent most of the time).
Works just like a normal 2D sprite now... but the texture will repeat and you can make whatever shape you want in your modeling program.
For the collider, you can add any type of collider you want. If your shape isn't standard, you'll probably want an Edge Collider 2D or a Polygon Collider 2D.
I would suggest you the following:
Create a polygonCollider2D directly in unity as you need it
Add a mesh filter and a mesh renderer
Add a custom script made by yourself, in which you convert the Collider polygon to a mesh (Mesh that will be used on your MeshFilter at runtime).
3.1. In order to do this, just copy the vertices of the polygon
3.2. Use the triangulator class in this link to help you create your mesh (http://wiki.unity3d.com/index.php?title=Triangulator)
Enjoy
If you want to see the custom script find it here: http://answers.unity3d.com/questions/835675/how-to-fill-polygon-collider-with-a-solid-color.html