Search Issue Tracker
By Design
Votes
0
Found in
2017.3.1p3
Issue ID
1022365
Regression
No
Mesh.bounds.center returns word space position instead of local space
Steps to reproduce:
1. Open the attached project
2. Open the SampleScene.unity scene
3. The scene contains empty gameobject(Parent) and cube as a child gameobject
4. Cube's word space position is (0,0,5)
5. Play the scene
6. Observe the Console Window, it prints (0,0,5) instead of local space position as a documentation states
Reproduced with: 2017.1.3p2, 2017.2.2p3, 2017.4.1f1, 2018.1.0b13, 2018.2.0a7
Note:
https://docs.unity3d.com/ScriptReference/Mesh-bounds.html
Actual results Mesh.bounds.center returns word space position
Expected: Mesh.bounds.center should return local space position
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
marctem
Apr 30, 2018 15:59
Mesh.bounds.center _does_ return local space position. The code in your example project is using GetComponent<MeshRenderer>(), and as noted in the docs you linked, MeshRenderer.bounds.center returns world space position.
If you want local space, you should use GetComponent<MeshFilter>().mesh.bounds.center.