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
- Warnings in the Bug Reporter window are cut off and not truncated when the Bug Reporter window is resized to its minimum size
- Color is incorrectly applied to objects when initialized with non-normalized parameters
- SerializationUtility.GetManagedReferencesWithMissingTypes() don't return null when “Prefab has missing SerializeReference Types“ warning banner is present
- Memory leak when VFX Graph is open and Camera has "Target Texture" enabled
- The Canvas component's warning box is missing an apostrophe when Additional Shader Channels is set to "Normal" and "Tangent" with Render Mode set to "Screen Space - Overlay"
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.