Game Maker

Entity Enter / Leave Region

Trigger actions when a non-player entity enters or leaves an area.

These events function identically to their player counterparts but work for any non-player entity.

Entity Enter Region

Triggers when an entity enters the boundaries of a region.

  • Action Values: Entity
  • Use Cases:
    • Making mobs more aggressive when they enter an "arena" region.
    • Triggering a dispenser trap when a mob walks over it.
    • Counting how many mobs have entered a specific zone.

Entity Leave Region

Triggers when an entity leaves the boundaries of a region.

  • Action Values: Entity
  • Use Cases:
    • Preventing mobs from leaving a designated area by teleporting them back in.
    • Despawning (killing) mobs that wander too far from their spawn point.

Example: Leashing Mobs to an Area

  1. Region: Create a region that defines the mobs' patrol area.
  2. Property: Create a Location property called MobSpawnPoint. Set its default value to the center of the region.
  3. Event: Entity Leave Region.
  4. Action: Teleport: Target the Entity that triggered the event and teleport it to the location stored in the MobSpawnPoint property.