Help file / Raycasting help

I’m reading the reference for Physics.Raycast here-

My confusion is that there are several different parameter combinations, often using the same number of parameters but for different things.

How does Unity (or more importantly me) know which parameter is what? Is it smart enough to know based on data type? For example knowing that I’m giving it hitInfo because it’s a Vector3 as opposed to distance, which would expect a float. This seems like the only explanation to me, but I don’t like to make assumptions.

Also, it seems that the layerMask parameter is optional in every case. How do I know when parameters are optional or mandatory, without guessing from the usage example? Is this something that always applies to the layerMask parameter?

I’m sorry if this is a stupid question, but it’s hard to help myself from the help files when I’m too stupid to understand the help. :stuck_out_tongue:

unity is smart enough to do that. raycast has multiple method definitions, if u use the raycast function, unity looks for the definition which fits the parameters you supplied, if there is none, it throws an exception.

layerMask is not optional, those are 2 different method definitions, 1 with and 1 without layerMask as parameter