Raycast not detecting planes

I have some randomly generated planes, but, I added a script to make them send a raycast upwards to see if there are any more planes above them. The planes are rotated at Vector3(90, 180, 0).

function Start(){
    yield WaitForSeconds(1);

    if(Physics.Raycast(transform.position, Vector3.back, 2)){
        Instantiate(so on...)

I can’t find out what’s wrong…

Planes are single sided non-convex objects. You can only see them on one side (the side the normals are facing) and if you use the default Mesh Collider you can only collide with them on the visible side. To check a collision from ‘behind’ the plane you need to work around this. Here’s a few ways you could do it:

  • Use a Box Collider with nominal height (0.01 or something depending on the scale of your scene) - this is probably the easiest solution
  • Use two planes, one facing in each direction
  • Model a two sided plane yourself and use this instead of the Unity primitive

Note that you may want to use a Quad instead of a Plane primitive for performance reasons. A Quad only has 2 triangles so will be better for rendering, and also physics performance if using a mesh collider.

Add a cube collider to the plane, this would work better than a mesh collider or whatever you are using.

As a Variant, because a Planes is a single sided, You can change Ray to opposite direction (sent not from start to start + direction, but sent from start + direction , to start)

Do they have colliders? And if so, are they mesh colliders? Unless they are double sided planes if they are facing away from the raycast it may go straight through them.

If the planes are box shaped you may want to give them box colliders instead, that could be faster than mesh colliders anyway.