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
- Mouse input is registered incorrectly in Custom RP when downscaling Render Target and rendering Overlay UI before final upscale
- Time.deltaTime is locked to the display's refresh rate when the built Player is moved to a Secondary Display and Windowed Mode is used
- Crash on RaiseException when importing a specific asset
- Crash on RaiseException when opening a specific project
- DownloadHandlerScript.CompleteContent is called twice when building for WebGL
Add comment