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

Physics

-

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

  1. 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

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.