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
- [Android] Stage information is not logged when Log Shader Compilation is enabled
- [Vulkan] The memory allocation increases rapidly when there are multiple (three or more) Real-Time Reflection Probes in the Scene
- [macOS] Library folder of the opened project can be deleted which leads to the crash
- “Default Scene” dropdown field contains a spelling mistake “Default Builtin”
- Editor crashes on PPtr<Mesh> after adding Text Mesh and Cloth Components to the same GameObject
Add comment