@urth/metatell-sdk/user lets a plugin enable or disable the current user's
movement. A typical use is to stop the player from walking around while a game
is in progress.
import { setMovementEnabled } from "@urth/metatell-sdk/user";
// when the game starts: block movement
setMovementEnabled(false);
// when the game ends: restore movement
setMovementEnabled(true);
The same function is available as user.setMovementEnabled() on the root
entry. enabled must be a boolean; otherwise the call throws an Error. If the
host store is not ready, the call is a no-op and logs a warning.
This runs in the browser-side plugin runtime. The metatell host must provide
window.APP at runtime.
setMovementEnabled changes a persistent preference. This is the same value as
the one on the settings screen, and it does not reset automatically when the
plugin closes.
For this reason, your plugin's teardown logic must always call
setMovementEnabled(true) to restore movement. If you skip this, the user stays
unable to move even after the plugin is closed.
function teardown() {
setMovementEnabled(true);
}
setMovementEnabled(false) only blocks translational movement (WASD /
joystick). The following are not blocked:
If you also need to block rotation or warping, that requires separate handling.