Primitive colliders on complex model in Unity - unity3d

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.

Related

How to create a collider with a physic friction for a racing track in Unity

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

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.

Wheel Collider has different rotation with the wheel GameObject

I want to add a wheel collider in my car wheel but it comes with 90-degree rotation.
This is the image:
How can I adjust the collider to the car wheel?
For further reference, i am writing down my comment as answer.
Simplest solution that i can think of is; add an empty gameObject. Attach wheel collider to that empty gameObject. And make the empty gameObject child to your car's wheel. With this you can rotate the empty gameObject so that your collider will be rotate. #Programmer also shared a link about WheelCollider Tutorial. Which can be found here
One of the best thing you could do is that, before importing the game object, make sure that the game object is Y Forward. You can change that in blender while exporting.
I had the same problem. However, simply rotating an empty parent object doesn't work in the modern version of Unity (2019.4). You have to rotate an object that has the rigidbody that the WheelColliders are attached to.
Assuming that your car has a rigidbody, the solution is to make sure that the X-axis orientation of the car's rigidbody matches the desired X-axis orientation of the wheel colliders.
Based on this post:
https://forum.unity.com/threads/unity-5-wheelcollider-wrong-rotation.349596/#post-2264801
WheelColliders always point in the "forward" and "down" direction as the rigidbody they're attached to. The steerAngle value is relative to the rigidbody's forward direction.
Please bear in mind, however, that your car's model(the visuals that display the car body) might have a different orientation from the object that contains the rigidbody that wheel colliders are attached to.
In my case Hierarchy looked like so:
MainScene
CarRoot
CarModel
WheelColliders
Wheel_FR
Wheel_FL
Wheel_RR
Wheel_RL
The CarRoot had a rigid body on it. When I rotated it, it would rotate the wheel colliders with it. That would also rotate the car model. Which was not good. So I had to:
Unparent the CarModel and WheelColliders(made them children of MainScene)
Rotate the CarRoot by 90 degrees on the Y-axis(to align its X-axis with that of the WheelColliders)
Make CarModel and WheelColliders children of CarRoot again.
That did it for me.
P.S. Sorry if this is a bit of a necro-bump. But this still has no answer.
I had a ton of trouble over this because none of the export settings or rotations in Blender fixed the problem for me. I eventually found a solution though. Create an empty gameObject, and attach the rigidbody, mesh filter, and mesh collider to it. Then parent the model to the empty gameObject, and then try adding wheel colliders. Wheels are relative to the rigidbody's transform.up and transform.forward, so putting the rigidbody on a default thing fixes all the issues.

Rigidbody between two terrains getting dragged to the upper one

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.

Unity3d - Create new gameobject from existing objects in unity

I am beginner in Unity3d. i would like to ask you about creating new gameobject from exsiting objects in unity3d.
I want to to create new gameobject from existing spheres and squares in unity3d. Right now, i only drag them to become a group. In addition, I want spheres and squares in the new gameobject not to effect collider together.
The new object only collide with other outside objects. How i can do it?
More a question, i would like to create a hoop object in Unity3D, Has already hoop object existed in Unity3D? It has not existed yet, please tell me how to create it? and the space is at middle of hoop not to effect collider ??? Thanks so much,
If my question is not easy to understand, i will edit.
Sounds like you're after a Prefab.
Once you've created your prefab, you might want to Instantiate it.
To avoid collisions, make sure your prefab does not have a Collider component. Simply remove the component inside the prefab.
A hoop shape is also known as a taurus or a donut. This isn't available as a primitive in Unity3D but it is very easily created in 3D modelling programs and used within Unity3D's mesh import.
As Nathan pointed out, create a prefab from your objects.
It looks like you want your objects to act like a compound collider (see Compound Colliders section here). You need your objects to have Collider components, and you need to add RigidBody component to their parent GameObject.
About torus collider: http://forum.unity3d.com/threads/27906-Adding-a-new-collider-primitive