Search Issue Tracker
By Design
Votes
0
Found in
2020.3.45f1
2021.3.20f1
2022.2.9f1
2023.1.0b6
2023.2.0a4
Issue ID
UUM-28417
Regression
No
Phsyics.Raycast throws a NullReferenceException when used without the maxDistance argument
Reproduction steps:
1. Open the attached “Repro.zip” project
2. Open the “Assets/Scenes/Puzzle.unity” Scene
3. Enter the Play Mode
4. Press on the Rubik's Cube on the left side of the Game View
5. Observe the Console
6. Press on any of the white cubes on the right side of the Game View
7. Observe the Console
Expected result: No errors are present and “Hit something in the Input Layer” is printed in the Console
Actual result: NullReferenceException is thrown and “Hit something in the Cube Layer” is printed in the Console
Reproducible with: 2020.3.45f1, 2021.3.20f1, 2022.2.9f1, 2023.1.0b6, 2023.2.0a4
Reproducible on: Windows 10 (21H2)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Some UXML Template Asset foldouts appear enabled when all fields inside are disabled
- URP Terrain Demo crash on burst_signal_handler after Generating lighting
- Project window button icons are poorly visible and their shades differ in Light theme
- GC.Alloc called by HDRenderPipeline.LensFlareMergeOcclusionDataDrivenPass() when playing the default HDRP Sample Template project
- Automatic LOD fails and SRP Batcher incompatibility occurs when using spline-based quad-topology meshes
Resolution Note:
Physics.Raycast doesn't throw the exception here, a user script that looks for a component after registering a hit does.
Also the LayerMask is being passed as maxDistance, that's why the raycast is returning an unexpected hit.