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
- “Remove Unused Overrides” available on not loaded Scene and throws “ArgumentException: The scene is not loaded” warning
- Adaptive Probe Volume occlusion edge is calculated incorrectly when viewing probes near geometry edges
- Sampling a texture using an HLSL file throws shader errors and the code does not compile
- "Graphics.CopyTexture called with null source texture" error when Base Camera of an Overlay Camera is removed with DX11 Graphics API and Compatibility Mode enabled
- WebGL sends wrong value with large numbers when SendMessage function is used
Add comment