PolyTrigger2D + StateMachine2D — Two engines. One toolkit. The Godot-style layer RPG Maker MZ was missing.
Get discounts and free plugins on the Discord server
https://discord.gg/W4HSw695kP
PolyTrigger2D gives every event a real geometric collision shape (circle, rect, ellipse, custom polygon) with rotation, follow-direction vision cones, Godot-style named layers, and async proximity signals — no parallel events, no touch required.
StateMachine2D turns every event into a finite state machine with unlimited states, behaviors (chase, flee, patrol, wander, follow), signals, async coroutines, and a visual plugin-command workflow that any beginner can use.
Together, they form a complete AI + physics layer: shapes detect, the FSM reacts. NPCs that see you, chase you, flee, ambush from zones, trigger cutscenes on vision cones — all without a single parallel process.
Both plugins will be updated until they’re perfect. Found a bug? Want a new behavior, a new shape, a new signal? Tell us — we’ll build it. This toolkit grows with the community.
Part 1 — PolyTrigger2D (Area2D)
Real geometric collision shapes for every event. The Godot Area2D layer RPG Maker never had.
What It Does
Attach a shape to any event or the player. The shape is not bound to the grid — it lives in pixel space, with offset, rotation, and named physics layers exactly like Godot. It fires async body_entered and body_exited signals when anything overlaps it — no bumping, no touch, no parallel process. Zones fire the moment something enters them.
Features
- Four shape types — circle, rect, ellipse, custom polygon (3-16 vertices)
- Rotation — shapes rotate with the event, any angle, in degrees
- Follow Direction — vision-cone style, turns automatically when the event turns
- Godot-style Layers & Masks — 16 named physics layers (“Player”, “Enemy”, “Trap”…)
- Async proximity signals —
onEnterActions/onExitActionswith one textbox - No parallel events needed — signals fire by themselves on proximity
- No touch required — works with any MZ trigger type (0/1/2/3/4)
- Debug overlay — always visible or F10 toggle, cached for zero redraw cost
- Area Forge tool — draw shapes visually, export notetag / comment / script
- Zero-alloc hot path — 200 active areas stay at 60fps
- Pixel movement safe — uses
_realX/_realYwhen present (Altimit, QMovement) - Self-diagnostics —
diagnose(id)tells you exactly what’s wrong - Zero dependencies — works standalone
What It’s For
- Vision cones for stealth enemies
- Circular healing zones
- Rectangular trap fields
- Polygonal room triggers
- NPCs that notice you when you get close
- Projectiles that check for nearby targets
- Zones of any shape, aligned to any direction
Part 2 — RPX StateMachine2D (FSM)
Give every event a real finite state machine. Replace nested branches, parallel switches, and page spaghetti with readable states.
What It Does
Define states in the event notebox or page comments. Each state has a behavior (what the event does automatically), an optional animation, and optional enter / update / exit JavaScript. Transitions fire on conditions, signals, or proximity. It’s compiled once at parse time, so there’s zero per-frame parsing cost.
Features
- Unlimited states — add them from notebox, plugin commands, or script at runtime
- 8 built-in behaviors — none, idle, wander, patrol, chase, flee, approach, follow
- Full JS bodies — enter / update / exit with
this= character, unlimited code - Async coroutines —
await this.waitFrames(60),waitSignal,waitCondition,waitState - Signals — arbitrary named signals, state-local or global, sent from script or plugin command
- Transition conditions — full JS with
thisin scope, bare helpers auto-fixed - 1-click triggers —
AddTrigger approach/leave/touch/actionkey/polyEnter/polyExit/always - Movement helpers —
moveTowardPlayer,moveAwayFromTarget,moveTowards(x,y),distanceToPlayer - Debug overlay — state name rendered above every event, F7 toggle, cached PIXI.Text
- Self-diagnostics —
StateMachine2D.diagnose(id)+selfTest()headless suite - Save/load safe — only plain data saved; compiled functions rebuilt after load
- MV fallback — also works on RPG Maker MV via pluginCommand
What It’s For
- Guards that patrol, notice you, chase, attack, return
- Animals that wander and flee when approached
- Bosses with phase changes and telegraphed attacks
- NPCs that react to story flags and quest states
- Ambush encounters with vision cones
- Cutscene actors with scripted behavior
- Any event that used to be 6 pages of nested branches
Example — Guard in 12 lines
<State: GUARD>
behavior: patrol
range: 4
anim: slime_idle
transition: CHASE if this.isPlayerNear(6)
</State>
<State: CHASE>
behavior: chase
anim: slime_run
transition: ATTACK if this.isPlayerNear(1.2)
transition: GUARD if !this.isPlayerNear(9)
</State>
<State: ATTACK>
behavior: none
enter: this.playAnim('slime_attack');
update: this.processAttack();
transition: CHASE if this.stateTime() > 60
</State>
