We created a scene and object for two different levels of our game. Created script for detecting collision. In one case Collision.contact.normal.y is giving proper values for the game. But the same script on another level giving a value like 0.9999998 which seems to be a single value which is not expected. Any clue on this?
All those values are floating point values. A Vector3 is made up of 3 float values. 0.9999998 can be considered as 1.0. This is a general precision problem.
You never should direct compare floating point values, they would almost never match.
So if you want to check if the normal is pointing upwards, just test for a range like this:
It would help to know what you actually want to do. You just described a common, well known phenomenon, so we can't say much more about this without more information.
answered Jul 09 '12 at 11:17 AM