Basically I have an object which sends 2 raycasts out downwards to detect if anything is hit, I’m using this code:
if (Physics.Raycast (Vector3(transform.position.x + 0.3, transform.position.y, transform.position.z), -Vector3.forward, hit, ydist, layerMask) || Physics.Raycast (Vector3(transform.position.x - 0.3, transform.position.y, transform.position.z), -Vector3.forward, hit, ydist, layerMask)) {
}
They’re hitting objects but not in the correct direction, it’s odd because I also have rays firing out upwards, left and right and they all seem to be working correctly. The image below shows what I mean, the object with the x on it is the object which the script is contained on and the red line denotes the direction that the raycast should be fired (using Debug.Draw). The box which is outlined in red is the box which is hit which clearly isn’t right.
Any help or ideas would be GREATLY appreciated.
Edit Note : Even if I reduce both of the “0.3’s” to 0 it still doesn’t work so thats not the problem