UdonSharp: RaycastHit.collider becomes null when Physics.Raycast maxDistance is read from a custom property
Guff-ppp
When a custom property is used directly as the
maxDistance
argument of Physics.Raycast
, the method returns true
, but hit.collider
is null
.Assigning the property value to a local
float
before the call avoids the issue. Both versions cast the same ray against the same Collider, so they should return the same RaycastHit
.The issue occurs with both auto-properties (
{ get; private set; }
) and non-serialized getter-only properties.A property getter appearing after an
out
argument may be related, but I have not confirmed the exact trigger.The full reproduction code is attached as a screenshot.
Photo Viewer
View photos in a modal
Log In
Guff-ppp
Additional note: The same code works correctly in a regular MonoBehaviour.