RaycastAll vs Collider.Raycast gives different results
Asked Answered
S

5

0

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?


Seeing answered 1/7 at 6:25 Comment(0)
S
0

I filed a bug report and Unity QAs managed to reproduce it. It have been sent do Unity devs and hopefully will be fixed in upcoming release of the editor.

Seeing answered 13/6, 2018 at 7:31 Comment(0)
K
0

Apparently, the bug still hasn’t been fixed because I’m getting the same error…

Kekkonen answered 3/4, 2020 at 20:53 Comment(0)
H
0

I am having the same problem in 2019.3.
Is there a way to check bug reports and see if it’s still open?

Haematogenesis answered 24/6, 2020 at 17:34 Comment(0)
C
0

Same issue in 2020.3.48f1. Is the bug tracking link available? Was this fixed?

Clammy answered 1/7 at 5:10 Comment(0)
B
0

Extremely unlikely. Consider, for example, this caveat:

If one is a newcomer to any mature tech it’s most productive to always assume you don’t understand something about it yet - or - the bug is in your code or data.

Boone answered 1/7 at 6:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.