unity-game-enginegame-developmentcollider

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


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


Solution

  • 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.