I'm trying to debug the following situation:
The raycast returns miss even though it clearly hits its target collider.
The target is a stock 3D Object Unity Cube. The script firing the rays has a Public GameObject called 'target', the cube is correctly set as the target.
Here is the bulk of the raycasting I am doing. The rays are aimed at an array of positions within the bounds of the box called 'vertices'.
This was working yesterday and I didn't change the code and now it no longer works and I am completely stumped with no idea how to even begin to debug why.
for (int i = 0; i < vertices.Length; i++) { Vector3 direction = vertices[i] - self.position; Ray ray = new Ray(self.position, direction); if (Physics.Raycast(ray, out raycastHit)) { if (raycastHit.collider.transform == target) { Debug.DrawRay(self.position, direction, Color.green, 5.0f, true); hitCount += 1f; } else { Debug.DrawRay(self.position, direction, Color.red, 5.0f, true); } } } 
raycastHit.collider.transform == target. If you don't want to use the transform, change it toraycastHit.collider == target. \$\endgroup\$