google-deepmind / google-deepmind/mujoco
Wrong HField vertical scaling in unity plugin
- Dominant language
- C++
- Stars
- 15.2k
- Forks
- 1.8k
- Avg merge
- 10d 16h
- Merged PRs (30d)
- 25
Description
# Description
_Video with the problem is attached below_
When using a terrain (hfield geom) in Unity, physics collisions may not match the rendered visuals. This happens in case when terrain data contains heights in smaller range than [0..1]. For example, if terrain is a flat plane at height 0.7, mujoco will think that highest point is at height 1, and collision will happen at height 0.7 * 0.7 = 0.49. But as soon as we add one point at height 1, everything starts working correctly.
# Steps to reproduce
1. Create empty project in Unity and add MuJoCo package
2. Import the attached .unitypackage file ([HFieldBug.zip](https://github.com/user-attachments/files/16767225/HFieldBug.zip))
3. Open the scene and hit play (notice how the cube falls through the terrain, but then stops)
4. Stop simulation and tick the "Add Workaround Point" on "TerrainCreator" object
5. Hit play (notice that the cube no longer falls through)
# Video
https://github.com/user-attachments/assets/e3e6b9f9-d32d-403b-b1a3-ddc5871701d5
# Versions
_It probably does not depend on particular versions, but I'm gonna include them anyway_
**OS**: Windows 10
**MuJoCo**: 3.2.0
**Unity Editor**: 2022.3.28f1
Contributor guide
Assessment
This issue has not been assessed yet.