Is this a bug in the raycasting documentation?

Hi all, i’m going through the unity tutorials, and i found a line which is odd:

This compiles:

    if(Physics.Raycast(checkPos, player.position - checkPos, out hit, offsetMag))

That is, (Origin, direction, Hitinfo, distance)

But this does not:

if(Physics.Raycast (checkPos, player.position - checkPos, offsetMag, out hit))

That is, (Origin, direction, distance, Hitinfo)

This makes no sense according to the documentation. The full list of polymorphs is as follows:

Origin, Direction, Distance, Layermask
Origin, Direction, Distance, Hitinfo, Layermask
Ray, Distance, Layermask
Ray, Distance, Hitinfo, Layermask

How does this make any sense? Clearly according to the documentatin, the former is wrong and should not compile, while the latter is a match and should compile. The situation in practise is inverted

PS: I’m very sorry for writing this whole post in code tags. the formatting kept getting messed up and it seemed like the easiest way to fix it

I don’t see any documentation where Hitinfo comes after Distance:

  static bool Raycast(Vector3 origin, Vector3 direction, RaycastHit hitInfo, float distance = Mathf.Infinity, int layerMask = DefaultRaycastLayers);

P.S. Note that anything indented 4 or more spaces is treated as code. I made a pass on your question and removed the indents for the non-code areas.

Where do you see

Origin, Direction, Distance, Hitinfo, Layermask

It’s

Origin, Direction, Hitinfo, Distance, Layermask

according to the docs, intellisense and ILSpy :wink: Hit info never comes after the distance