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
- Texture Import Warnings are obscured by other Terrain Layer options in the Inspector
- Burst Inspector middle divider is jittering when resized with the Burst Inspector window docked
- JsonConvert conversion fails trying to call GetCallbackMethodsForType when [OnDeserialized] is used in a class
- Different text alignment in the column header in Entities "System" window
- Objects with Universal Render Pipeline/Particles/Lit shader are always lit up when changing their Rendering Layer Mask
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.