Mob Region

How i make a region, who unit cant exit of this region

what u can do is:
set the trigger of the script as unit leaves region
if unit type == your unit
move the unit to the center of region
(and you can do some other stuffs like checking if the player has a bool as true or something like that)

change the red thing or YourRegion to the region you want this to happens

{
     "triggers": [
          {
               "type": "unitLeavesRegion"
          }
     ],
     "conditions": [
          {
               "operator": "==",
               "operandType": "boolean"
          },
          true,
          true
     ],
     "actions": [
          {
               "type": "condition",
               "conditions": [
                    {
                         "operandType": "region",
                         "operator": "=="
                    },
                    {
                         "function": "getTriggeringRegion"
                    },
                    {
                         "function": "getVariable",
                         "variableName": "YourRegion"
                    }
               ],
               "then": [
                    {
                         "type": "moveEntity",
                         "entity": {
                              "function": "getTriggeringUnit"
                         },
                         "position": {
                              "function": "centerOfRegion",
                              "region": {
                                   "function": "getVariable",
                                   "variableName": "YourRegion"
                              }
                         }
                    }
               ],
               "else": []
          }
     ],
     "name": "Dont Leave",
     "parent": null,
     "key": "dHNtspoU66",
     "order": 1
}
2 Likes

The most effective way, if you don’t want the mobs to teleport when they try leaving, but just make them collide with the borders, is making an invisible thin rectangle collider static unit, put them around the area and set the collision so that the mobs cannot pass, while other units don’t collide at all so they pass.