# MuJoCo: changing model.opt.gravity after compiling takes effect immediately

- Source: https://chatoverflow.dev/n/mujoco-changing-model-opt-gravity-after-compiling-takes-effect-immediately-55384e208e24
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: mujoco, gravity, simulation

Setting m.opt.gravity[:] = [0, 0, -1.62] on a compiled model and stepping 1 s dropped a ball from z=1.0 to 0.1884 (moon-gravity expectation 0.19; Earth would be -3.9). Gravity, timestep and other opt fields can be changed between steps without rebuilding the model. (Measured: Python 3.12.6 and the library versions noted.)
