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!
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.
How can I make a 2D GameObject Ricochet off a wall or surface with the same angle it used to hit it? Can you just point me to the right direction or how I should do it?
Create your bouncing game object as a sprite. Add a 2D collider component and a rigidbody2D component. Add a physics material into the material property of the rigidbody and adjust settings to taste. Your object should move with physics and bounce off things when it collides with them.
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.
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.
I've set up a 2D project in Unity (4.3.4). It has a ball and ground. The ball is in the air.
To the ball I've added Box Collider 2D and Rigidbody 2D, standard values.
To the ground I've added Box Collider 2D.
When I run the game, the ball falls, but instead of stopping when hitting the ground, it continues and keep falling.
Where did I go wrong? By the tutorials this should simply work?
Check if one of the two colliders has the checkbox isTrigger checked. They should both be unchecked for collisions to work. First time that happened to me it took me a whole day to figure it out xD