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
- Mono Windows Builds don't produce full log callstacks when generating logs
- AssetBundles fail to load when running in Built Players for Mobile Devices
- UI elements with text gets bigger and grey when Player window is moved to another screen with different resolution
- System name accepts multiline text but crops it on confirmation, duplicates input, and shrinks the field when empty
- UI element scale and position are wrong in project build when DRS is changed with HDR and Software Dynamic Resolution enabled
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