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
- Crash on when D3D12RenderPass::SetupDeviceResources when opening FBX animation preview
- Serialization errors are thrown when "com.unity.render-pipelines.core" is added as a custom package and Graphics window is opened
- Character Joints unexpectedly rotate when a ragdoll is created using the Ragdoll Wizard
- Crash on GfxDeviceD3D11Base::DrawBuffersBatchMode when rendering the Scene view
- The shared EditorBuildSettings.asset file of symlinked projects is not updated when changing the order of the Scenes in Build Settings in one of the projects
Add comment