How to determine when player (cylinder) has moved above a plane in unity 3D? - unity3d

I am making a delivery game and temporarily designed my game so that the player who is a cylinder at the moment has to locate the delivery location which is a flat plane and move onto it in order to deliver the objects.
I have tried adding a 2d box collider to the plane to detect when the player collides with the plane but the collider only works on the x,y axis and i am not able to rotate it 90 degrees.
So my question is what is the best way to determine when the player has moved above the plane?
Here is a picture to demonstrate what i mean:
Before moving onto plane
How to i detect this:
Player is on top of plane

First, make sure at least one of the objects has a rigid-body component. If you are using a character controller to control your player, add the rigid body to the plane. If you don't want the rigid body to affect the plane, just freeze all the position and rotation constraints. Next, make sure both of the objects have a 3D collider, not 2D. Your game is 3D and needs 3D colliders. 2D is for 2D games such as sprites. (I recommend a cylinder collider for the player and a box collider for the plane.) Make sure the plane's collider "isTrigger" is enabled. This should work for you to detect the collision.

Related

How to make that 2d collider dont slide on on an inclined plane

If 2d collider with rigidbody with freezed Z rotation touches an inclined plane with its lower edge, then it begins to slide down, how to get rid of this effect? I want if rigidbody edge touch the inclined plane, rigidbody should keep his own position and dont slide down.
I agree with BugFinder, a frozen rotation on a Rigidbody will not affect the interaction between the collider and the inclined plane. You should create a new PhysicsMaterial and assign it to your Collider that is assigned to your Rigidbody. Increase either its staticFriction, dynamicFriction, or both, as well as experimenting with the frictionCombine option, which will change how the friction value of your Rigidbody will interact with the collider of the inclined plane.

Ball moving in tube with rigidbody

Lets say you have a sphere(rigidbody, sphere collider) inside a tube(mesh collider). I want a ball to move in the direction of tube always by applying force on rigidbody.
My purpose is to simulate the circular gravity, so that ball can fall down back obviously in circular motion. This was the approch i was using to simulate fake circular gravity.
How can I check which direction of force has to be applied to continue motion following the path of the tube with addforce?
try applying physics material to your tube to control the ball reaction to the surface of the tube.

How to flip the normals of the collider mesh in Unity

I have a sphere in Unity and have used a script to flip the normals so I can see a 360 texture on the inside. I'm doing this because eventually I want to play a video on the inside, and also have other spheres inside hat can be thrown around and bounce off the inside walls of the outer sphere. The problem is, despite the normals of the sphere facing inwards, the collision is still standard. Objects within the sphere just fall straight through.
Do I need to add to my script to include the collision mesh?
you cannot have non-convex MeshColliders behave as Rigidbodies in Unity, you need to fake the walls as a series of convex colliders, approximate with box colliders maybe?

Unity 4.5 Mesh Collider Not Interacting with Circle or Box Collider 2D

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.

Can a Polygon Collider 2D work with a Mesh Collider in Unity?

EDIT: This is now a rather simple question. I have a 2D sprite that really needs the precision of a polygonal hitbox. The 2D, tile-based world around it uses a tile Mesh for efficiency reasons, and thus has a Mesh Collider.
Before, the tiles in the world were each GameObjects with Box Colliders and Rigidbody 2D's, and the ship and the tiles collided just fine. Now that I am using a Mesh Collider, however, they cannot collide. (I have read that this is because one is 2D and one is 3D.) So what should I do to get collisions (preferably with rigidbody physics) between a polygonal ship and a 2D tile mesh? [end edit]
In a 2D, tile-based, procedurally-generated, chunk-based exploration game (in Unity 4.5), I have a player ship which uses a Rigidbody 2D and a Polygon Collider 2D for collision detection.
This worked fine back when I used a Rigidbody 2D / Box Collider 2D for world tiles. However, this is horribly slow, so I replaced the discrete blocks with a tile mesh, using a Mesh Collider and other associated paraphernalia.
The problem is: I simply cannot get collision detection to work. I have tiles on the x-y plane, and the collision mesh (I can see it in the Scene View, so I know it works) consists of four rectangles perpendicular to the tile. (If you can't visualize this, I don't blame you. See here.)
What have I looked at so far? Well, I verified that the (2D) ship actually passes through the collision boxes in the Scene View. Also, neither of the colliders "Is Trigger".Since there seems to be no official documentation on how to actually use meshes (is there? Where?), I can't find out whether Mesh Colliders and Polygon Colliders actually can interact. Because one is 2D and one is 3D, does this not work? If so, then what should I do instead? I tried using a Box Collider [3D] for the ship, but this didn't work either. I could have potentially made a mistake here, though.
Am I supposed to handle the collision manually (with the OnCollisionEntered [or something] method)? Before, the rigidbody2D objects handled everything automatically. Otherwise, is there any other possible reason the collision might not work?
Well, I'm quite disappointed there seems to be no built-in way to do this in Unity. My solution was to attach a GameObject to the player that would read the block data from the world and create (pooled, of course) real but invisible "collider blocks" with Box Colliders 2D in a small area around the player, such that the player could collide with blocks near them. It works great, and I also implemented an algorithm to spawn rectangular collider blocks over groups of blocks; this eliminates the "ghost pixel" bug in the 2D physics engine.
Uni2D plugin (https://www.assetstore.unity3d.com/en/#!/content/3826) automatically creates 3d colliders (as a group of mesh colliders) from any 2 texture with transparency. A bit expensive but works.