RaycastAll
is supposed to return all objects on the path of the ray for specified distance, right?
RaycastHit[] hits = Physics.RaycastAll(ray, float.PositiveInfinity);
// DEBUG
string debug = "Raycast all gave " + hits.Length + " hits:";
for (int i = 0; i < hits.Length; i++)
debug += hits*.collider.gameObject.name + "; ";
Debug.Log(debug);
var colliders = GameObject.FindObjectsOfType<Collider>();
foreach (var collider in colliders)
{
if (collider.Raycast(ray, out RaycastHit temp, float.PositiveInfinity))
{
Debug.Log("Manually verified, that ray hits " + collider.gameObject.name);
}
}
// END DEBUG
On some occasions, I’m getting:
Raycast all gave 1 hits: "MissileExplosion(Clone)"
Manually verified, that ray hits "MissileExplosion(Clone)"
Manually verified, that ray hits "Falcon(Clone)"
Shouldn’t RaycastAll
return the same set of results?
What may cause that?
Is it a bug in Unity?