Search Issue Tracker
By Design
Votes
0
Found in
5.5.0f2
Issue ID
855431
Regression
No
[Physics] RaycastHit.transform does not match RaycastHit.collider.transform when the object has a parent
Reproduction steps:
1. Open the attached project ( 5.5b8_test.zip);
2. Open the "m.unity" scene;
3. Enter a play mode;
4. Observe the results in the console.
5. Then quit a play mode;
6. Drag the CubeChild from his parent object;
7. Repeat 3 and 4 steps.
Expected results: RaycastHit.transform and RaycastHit.collider.transform give the same results regardless the object is a parent or child of another object;
Actual results: RaycastHit.transform points on the parent object, but not on the child.
Reproduced on: 5.5.0a3, 5.5.0f2, 5.6.0a5.
Note: not reproduced on 5.4 and 5.3 due to the program crash (Unity crashes when I am trying to open the scene).
The case was closed by design: https://docs.unity3d.com/ScriptReference/RaycastHit-transform.html
"The Transform of the rigidbody or collider that was hit." - that means that if there was a rigidbody associated with the collider hit, it's transform would be returned instead. Note that if you want the other behavior, you might simply use collider.gameObject.transform instead.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Editor crashes on StoredGraphicsBuffer::GetGfxBufferID when VFX Graph property is modified during Play Mode and Application.targetFrameRate is used to limit FPS
- Crash on NVAPI_Thunk when changing Player resolution while HDR display is used and Direct3D12 is set as the graphics API
- Only one out of multiple cameras is shown in the Play Mode while HDR display is used and Direct3D12 is set as the graphics API
- The "Paste Component as New" option is incorrectly displayed as active despite the action being prohibited
- "TLS Allocator ALLOC_TEMP_TLS" errors are thrown when unsuccessfully importing an FBX file
Add comment