If a rigidbody is below a terrain it is getting dragged up on the terrain
I have 2 terrains, one over another to make a cave like shape. If I put a rigidbody on terrain below it is getting dragged onto the terrain above. So i cant even put a single rigidbody inside that cave.
I tried with mesh collider on terrain obove instead of using terrain collider. But terrain does not have an actual mesh, so it didnt work.
Is there a solution to overcome this?
Since Unity's TerrainCollider is height-map based, you can't put one on top of the other and expect proper collision detection.
Related
I have a car with 4 wheels, the wheels have their meshes and colliders separated with only 2 Empty GameObjects. As in [Car>Wheels>(WheelMesh+WheelCollider)]. The script works just fine but then I run the program and I am met with a car who's wheels are just awkwardly spinning. And to make matters worse even though I have perfectly aligned the Meshes with their Respective Colliders, what my eyes witness is just weird wheels who's mesh glitch into the ground. How do I correct it, or how to properly align or.. How do I directly link the colliders to their meshes?.
I tried to re-align the colliders and adjust their size to fit the mesh, I was expecting the mesh to move with the collider, but the mesh just does not sit with the collider, though the collider works fine.
My best suggestion will be to separate physic from model. You need to Have separate object for mesh and collider and after each LateUpdate update position of the mesh object.
I would be better if you can provide screenshot of hierarchy and how collider/model looks like.
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.
Instead walking on the ground he walk through it same for the ship and debris the other objects. He stay on the ground on the terrain but all the other objects in the scene he walk through it.
In the past i added Mesh Collider to the ship sapceship and checked the Convex turned the Convex on so it worked fine. but now i tried to add Mesh Collider almost to everything in the scene and it didn't change anything.
The scene is not my own but there is nothing speical i think. A terrain camera and objects. I added the ThirdPersonController.
Maybe there is a way to solve it making a new script in c# ? So far i could not find solution.
Make sure the collider of the Player is big enought to hold the model. And also that the terrain collider is adjusted to the terrain.
Try to change Center(Y) value of CapsulCollider
I just imported my tree model from blender and i want to add colliders to it. It has animation attached to it(tree is breaking and falling). I have read about adding colliders to animated objectsand from what I understood I just have to add many primitive colliders to different bones. My problem is that I can't rotate this primitive colliders and i cant make them fit shape of the object. Is there any better way to do this?
You could create an empty gameobject under the bone and add the collider onto that. The colliders rotation follows the rotation of the gameobject it was added to.