Skip to main content

Zone-Based

AnimZoneBase

This is a base-class TPT tile that can be used for defining a trigger area. Its purpose is to define an area on the Tilemap, specifically, a BoundsInt. Since it’s a subclass of TpFlexAnimatedTile, its sprite can be animated. If you don’t desire animation, just don’t add a SpriteAnimationClipSet.

Setting the zone size works in one of two ways, depending on the setting of the ModifySprite toggle. In either case, the ZonePositionAndSize fields let you move the position of the zone and the size of the zone.

If ModifySprite is checked (on), then as you change the area positioning and size, the tile’s sprite is transformed to encompass the trigger area. Since the tile controls the transform, transform modification in the TilePlusBase section of the inspector is unavailable. The VisualizeSprite button will highlight the boundary of the zone for a few seconds when clicked.

If ModifySprite is not checked (off), then the sprite isn’t modified as you change the zone size. The VisualizeArea button creates a persistent outline around the zone. The outline will be cleared if you click VisualizeOff or change the selection.

Public fields:

  • TileSpriteClear: Clear the sprite when painted, when the game runs, both, or not at all. The default for this tile is ClearOnStart. Note that that the sprite will be invisible, and you won’t be able to see the trigger area if this is set to ClearInSceneView or ClearInSceneViewAndOnStart.
  • Position, Size: Adjust the position and size of the boundaries of the Trigger zone. Unavailable when Lock All is checked.
  • ModifySprite: Controls whether the tile’s sprite is affected by zone size changes.
  • UseTrigger: If this is true then the tile’s MessageTarget (see TpLib.SendMessage) method will trigger an event if the passed-in position is within the Trigger zone. Note that the display of this field may be inhibited in subclasses, e.g., TpAnimZoneLoader.
  • Lock Position and Size: Prevent changes to X, Y, or Z position or Z size; or Lock All. (Editor-only).

Public properties:

  • ZoneBoundsInt: Get or Set the BoundsInt which describes the trigger area.
  • ZoneBounds: Get a Bounds based on ZoneBoundsInt.

Note that the bounds size can never be less than 1,1,1.

If you change the size of the sprite and there’s another tile in the same area it might be obscured by the transformed sprite (or vice versa). If that’s a problem, you can adjust the transparency in the Color field (TilePlusBase section of the Selection Inspector) or change the Tilemap Renderer’s Sort Order setting.

Plugins/TilePlus/Runtime/Textures/TriggerZoneSprite can be used for the sprite for this tile, but you can use any sprite. Note that the sprite won’t appear if you change the TileSpriteClear to Clear In Scene View. If you don’t want the trigger zone to appear in Play mode, set TileClearMode to Clear On Start.

The other action button for this tile is Reset Zone. Reset Zone does what you’d expect and resets the boundary to one tile space. This button does not appear when the LockAll toggle is checked.

At runtime, this tile is completely passive aside from animation. But with TpLib you can, for example, get a reference to every tile of this Type and use the trigger zones to do something when a playable entity enters or leaves a trigger zone. It’s very general-purpose, but how you use it is naturally bespoke to your own project. However, one common case might be to load more tiles to open a new area. That leads us to TilePlusAnimZoneLoader, a subclass that embeds information used to load TileFabs.

Note that the Tilemap Renderer will sometimes cull enlarged sprites. There’s a FAQ in the User Guide regarding this.

ZoneBase

AnimZoneLoader

AnimZoneSpawner

ZoneAnimator