Unity 2D polygon collider - unity3d

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. :)

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.

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

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.

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.

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.

How do you calculate the 2D Plane on which an array of Vector3 points are sitting on?

Assume you have a large array of Vector3 points. These points were plotted by hand by the player when asked to draw a 2d shape (i.e. a 2d triangle) in a 3-dimentional environment (drawing 2d shapes with htc vive controller in a virtual environment).
I would like to project these points on to a plane to 'flatten' the shape they drew. To do this properly I need to know the average plane they're sitting on so that there is minimal 'squishing/distorting' when projecting them on to it.
Basically, I want to ask them to draw any 2D Shape in the air (which won't be 2D because humans) rotated any way they want and convert that shape into a 2d picture with a known plane for further manipulation.
If you would like to know more specifics I would be happy to provide them.