Why Mesh Collider is not following 3D object's mesh exactly? - unity3d

I am new to Unity and having trouble with 3D physics.
I imported a basic 3D "U" bar shape and applied Rigidbody and Mesh Collider. When I drop another object let's say a ball, it does not go into the shape. When I select the shape, I realized a green line between to edges of the U shape which seems like Unity recognizes it as rectangular object.
How I can make Mesh Collider the follow imported mesh's exact shape?
Thank you.
Shape:
Properties:
Mesh Collider:

Your shape is not convex so if you check the convex option then Unity3d will modify collision shape to be convex. mesh collider not matching shape
To fix that, try to uncheck the convex option.

Related

Sphere collider but hollow inside

I want the sphere 2 to be hollow inside, so that the sphere 1 can proceed physics inside.
But I don't know which collider to use.
you could create a Sphere in a 3D modelling software and invert the normals so that they face inside the sphere. in unity place the sphere with the inverted normals as a child to your hollow sphere. this will represent now the inner side of your hollow sphere. remove the meshrenderer and add a meshcollider to the sphere with the inverted normals. now you can place any object with a rigidbody component attached to it inside and it will collide with the inner side of your sphere.
sphere with innerside to collide with
Just reverse Normals and use MeshCollider to fix problem.

How to set direction of arrows in shadergraph

I'm pretty new to shader graph and shaders in general. I'm working on a 2D project and I'm trying to make a shader that rotates an arrow to make a flow-like material and use it on a sprite shape.
Basically what I want to do is make a proper version of this:
What I'm currently doing is multiplying the Y position of the position node by an exposed vector 1 and using it in Rotate node (which I know is pretty hacky and won't work if the shape is not an arc.)
Aligning UV with arbitrary mesh seems bit hard. Why not bend pre-made mesh instead? Graph below bends vertex positions around axis Z at given point and strength (0 makes mesh invisible tho), but, you can easily replace that Position node with UV and plug results into Sample Texture 2D. I just guess bending a mesh will give you better/easier results.
Create a subdivided and well UV-mapped rectangle plane
Bend that plane with a vertex shader (attached graph bends around Z axis)
graph is based on code from Blender source

Shader is not working properly in my 2d game

I was looking for doing a sprite wave like water on a lake/ocean, i found a tutorial on internet, but it was for a 3d game, i applied the tutorial but the shader is moving the sprite in the Z axis, so the wave effect is not notizable from 2d view, but in 3d view it looks fine, it's a 2d game so i need it to move in the correct direcction, this is my first shader so i don't understand it so much.
Use a x=0, y=1, z=0 vector instead of the Normal Vector node.
That will make the wave motion go in the "upward" direction on the object instead of the "outward" direction.

Unity 2D polygon collider

Is there a way to create 2D polygon collider to work as as perimeter collider?
I want to be inside the polygon and do a raycast to the border. I want the hitpoint to be on the border, not on the location where I am.
Can I use 2D polygon collider for that or do I need to use some other collider?
You could create a polygon shape with 2D Edge Colliders. Just calculate the different spots with the polygon's angles.
I noticed there was an answer saying this already. My bad. :)

How can i add right collider for a cylinder with hold inside?

I have a cylinder with a hole inside.
I did the cylinder in blender and exported it to unity.
The problem is that the character walk through the cylinder and i want the character to walk inside but not through.
So i added a capsule collider component to the cylinder.
Now when the character walk in there like a floor since i changed the collider Center on Y to -1.5 and the Radius to 2 and the Height to 4.
The problem is if i will change the collider to be higher then the character will not be able to walk in the hole.
The collider component on the cyolinder settings in the inspector:
Either you put a meshcollider , or a mix of sphere and box colliders.