Your system needs to consider whether the object's surface is perpendicular to sensing direction, especially when the surface is flat and smooth. Different sensor has different directional characteristics. It should be stated in the datasheet.
I tried it and when I pointed the sensor at the floor (tiled) at an angle, it does not show any reading but when I put an obstacle in front of it, the sensor can detect it. Any reason or suggestions?
That is nature of ultrasonic or infrared sensor. It require reflection from obstacle/object, and there are using wave (sound wave for ultrasonic and light wave for infrared). Wave have reflection angle that we learn in physic. Search for wave reflection and you should understand it. Here is one link: http://www.physicsclassroom.com/class/waves/u10l3b.cfm