Making monsters move randomly in a set area?

I would like to have two slimes move randomly under a glass display, but I'm having trouble figuring out how. I have the sides of the glass tiles set as impassable so the player can't walk through it, but it makes it so the monsters unable to move within it. I remember reading that events can't move through other events, so I set up some blank events to try and cage them in...but they walked through those so I guess I read that wrong. Any way I can give them random movement and keep them within a specific 6 tile space?
Could use region restrictions to set the glass boss passable for events, but not the player and similarly around the box use a region that blocks events but not the player.

Could use region restrictions to set the glass boss passable for events, but not the player and similarly around the box use a region that blocks events but not the player.

Just making sure - these instructions only work with the linked plugin?
By default, an event can only move through another event if at least one of them is marked "Through", because that disables passability checks. (A plugin might change that in some cases, e.g. if I recall correctly Yanfly's Core Engine for MV disables it entirely for some reason. Maybe VisuStella have carried over that behaviour.)

Could you just use directional passability for the sides of the glass? That should allow the slimes to move around inside without escaping. The glass itself may be star-passable, but you could put other tiles, either outside the terrarium or layered on top of its glass edges, that are O-passable except in the relevant direction(s).

Another plugin option is EventMovableLimitation by triacontane:
It does require PluginCommonBase, which ships with RPG Maker MZ under:
  • <MZ install folder>/dlc/BasicResources/plugins/official/PluginCommonBase.js
(Standalone version might be organised differently.)
By default, an event can only move through another event if at least one of them is marked "Through", because that disables passability checks. (A plugin might change that in some cases, e.g. if I recall correctly Yanfly's Core Engine for MV disables it entirely for some reason. Maybe VisuStella have carried over that behaviour.)

Could you just use directional passability for the sides of the glass? That should allow the slimes to move around inside without escaping. The glass itself may be star-passable, but you could put other tiles, either outside the terrarium or layered on top of its glass edges, that are O-passable except in the relevant direction(s).

Another plugin option is EventMovableLimitation by triacontane:
It does require PluginCommonBase, which ships with RPG Maker MZ under:
  • <MZ install folder>/dlc/BasicResources/plugins/official/PluginCommonBase.js
(Standalone version might be organised differently.)
I'm not sure how changing the passability would allow them to move without escaping, except as you said by putting other things all around the...slime terrarium(?) - and I don't want to do that.

Thanks for the plugin link, I'll check it out along with the one Harlekin posted.
In case you're unaware: directional passability is one of the tile data options available on the right-hand side of the Tilesets tab in the database:

dir-passage.png
You can set certain tiles to be (im)passable only in specific directions. The directional blocks could be something innocuous like carpet trim, or just invisible tiles with specific passability settings~

(Note that directional passability doesn't work if the tile is set to Passage = star, because star means that tile is ignored for passability checks.)
In case you're unaware: directional passability is one of the tile data options available on the right-hand side of the Tilesets tab in the database:

View attachment 346274

You can set certain tiles to be (im)passable only in specific directions. The directional blocks could be something innocuous like carpet trim, or just invisible tiles with specific passability settings~

(Note that directional passability doesn't work if the tile is set to Passage = star, because star means that tile is ignored for passability checks.)
Oh my god I can't believe I forgot that function! To be fair I only ever used it once for a ladder over a year ago now, but still kind of embarrassing I forgot. That worked, thank you!
😮‍💨 Good thing I thought to mention it! No worries, it's easy to forget a detail here and there~
Galv Move Route Extras also has a move random on region function

Original thread: https://forums.rpgmakerweb.com/threads/making-monsters-move-randomly-in-a-set-area.179243/