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
- Crash on BatchRendererCullingOutputs::SyncFences when navigating through a Scene via the Scene view
- [Android][Vulkan] Crash on /system/lib/libandroid.so (ANativeWindow_setBuffersGeometry+4) when the Vulkan Graphics API is used
- Event handlers are preventing operations when trying to copy or paste HTML text in the WebGL Player
- [macOS] Crash on __pthread_kill when Exporting a Package while another export is in progress
- Crash on TransformAccessDestroyCallback when removing a URP Decal Projector component from a parent GameObject that had a URP Decal Projector child GameObject
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.