I added palm trees on my terrain. But I didnt add a mesh collider into the trees.
My car is able to pass through them.
How do I resolve this?
Make sure both the car and the trees have a mesh collider. Some more explanation of your problem would be nice.
Prefabs include a Capsule collider,Sphere collider or any simple collider is working but mesh collider when plant trees or any prefabs by Terrain Place Trees method.
A tree use Capsule collider is fine but a stone maybe use a simple mesh collider better than a Sphere collider. and unity don't let we do.
I solved problem with box collider. Box colliders are covering all of the trees and no problem.
Related
I've made a mesh from an SVG in Blender and converted it to a mesh. I then put it into Unity, to put a collider on it, the mesh does not collide with anything, even with convex ticked.
Here is my collider:
And here is my mesh in Blender (blue is the outside of the mesh):
What the convex collider looks like:
Can someone tell me why the collider is not working?
Cheers!
The MeshCollider is implemented in the 3D Physics engine and therefore incompatible with the 2D Physics engine. They simply don't interact.
What you probably want to use instead is the PolygonCollider2D
When working with Colliders and 2D, make sure you have the following:
RigidBody2D
Collider2D
In addition a Mesh Collider is a 3D implementation. If you want the 2D equivalent of a Mesh Collider in 2D, use a Polygon Collider 2D instead.
I created two game object.
One is box and the other one is a ball. Then I added collider them( box collider and circle collider) to collision them. But it's not working. When I hit play button, the ball just falling to eternity ^^.
I searched on the internet and looked for possible solutions and they didn't work.
*Is trigger unchecked.
*Attached rigidbody2d to the ball.
Any help will be appreciated. Thanks for your interest
The BoxCollider and CircleCollider2D interact with physics in different dimensions, box collider physics are calculated in 3D while circle collider physics are calculated in 2D. In Unity, 3D physics and 2D physics are calculated separately so collisions between 2D and 3D colliders isn't possible. You will have to replace your box collider with a BoxCollider2D or replace your circle collider with a SphereCollider. Best of luck!
I will briefly explain the problem.
I am developing a racing game and I wanted to know how to add some friction to my track.
I tried to add a terrain collider with a physics material to the track mesh but it doesn't work.
I am also very confused about how to add a collider to the track that respects its shape.
Thank you all in advance
You can use a MeshCollider component and add it to the track, this will form a collider around your complete mesh.
https://docs.unity3d.com/ScriptReference/MeshCollider.html
You could then apply a PhysicMaterial component to the track or your car(s) (you can add it to the collider). I believe a rigidbody component should also be added to the car, so that it can move with physics.
Mess with the values and read the docs:
https://docs.unity3d.com/Manual/class-PhysicMaterial.html
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 am new to unity and I am working on a 2D game. Currently, I am having trouble getting two colliders to interact when one of them is a mesh collider and the other is a box or circle collider. I was originally working to get the Unity Sample Assets 2D character to interact with a mesh terrain. When I "played" the game, the circle collider attached to the legs of the character was falling through the mesh terrain. I have simplified the problem and created two cubes:
One cube I upload and keep the 2d box collider and add a rigid body to
The second cube I delete the 2d box collider and add a mesh collider
I place the second cube under the first cube and hit "play". The top cube falls through the bottom box. When I replace the bottom cube's mesh collider with a box collider and hit "play" it correctly collides and stops on the box. I'm guessing I'm making the same mistake in this simplified example as I am in the more complicated 2D Character scenario. Do you have any suggestions of what I am doing wrong? I have tried making the mesh collider convex (although I believe this should only be necessary between two mesh colliders?). I have also ensured that the z position is the same as well as the layers of the two objects.
You cannot collide a 3D object against a 2D.
void OnCollisionEnter2D(Collision2D coll)
{
// Code here is clueless about 3D.
}
API Reference.
Sent when an incoming collider makes contact with this object's
collider (2D physics only).
You could cheat a little. Before Unity had 2D colliders what people would do is create a very thin box collider3D, which in your case should work.