Search Issue Tracker
By Design
Votes
0
Found in
2018.4
2019.2
2019.3
2019.3.0b3
2020.1
Issue ID
1185183
Regression
No
Raycast will ignore a set up LayerMask when and Object with such Layer has a Parent which has a RigidBody Component
Steps to reproduce:
1. Open user's attached project
2. Open SampleScene
3. Enter Play mode
4. Press "Space" key
5. Notice the console message "Shouldn't hit me"
Expected results: Raycast only hits Objects with Colliders and only GameObjects in Selected LayerMask
Actual results: If a GameObject has a Parent with RigidBody, the GameObject will not be hit even if it is in a specific LayerMask, Instead the Parent will be hit
Reproducible with: 2018.4.0f1, 2018.4.12f1, 2019.3.0b10, 2019.2.12f1, 2019.3.0b10, 2020.1.0a12
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
- Unity CIL Linker fails on Player build when persistent listeners have "<" and ">" in their XML attribute names
- ”Lighting data asset ‘LightingData’ is incompatible with the current Unity version…” warnings are thrown when saving Indoors (URP) and Outdoors (URP) Scenes as Scene Templates
- [iOS] The screen blinks when transitioning from custom to Unity splash screen
- [macOS] ”Ignoring depth surface load action as it is memoryless” warnings are thrown when taking Game View Snapshot
- UI Builder Inspector scrolls back up when changes on an expanded but not fully displayed Inspector tab are saved
Resolution Note:
This is probably counter-intuitive in 2019, but RaycastHit.transform is supposed to get you the transform of the rigidbody the collider is part of (the collider's transform otherwise). https://docs.unity3d.com/ScriptReference/RaycastHit.html