Skip to main content

Grid-Based Movement System

MCE uses a tile-based grid movement system built on Unity's Tilemap. The player and NPCs move one tile at a time on a discrete grid, with collision detection, terrain effects, and cross-map transitions handled by the grid system.

Core Components

GridController

The GridController is the per-scene manager for the tile grid. It:

  • Maintains the collision map for the current scene.
  • Tracks which tiles are walkable, blocked, or have special properties.
  • Handles tile-based collision queries (can a character move to tile X,Y?).
  • Manages tile data for encounters, warps, and special terrain.

Each scene has one GridController attached to its grid/tilemap root.

MCECharacterController

The MCECharacterController handles movement for any character (player or NPC) on the grid:

  • Grid-snapped movement: Characters move exactly one tile per step.
  • 4-directional movement: Up, Down, Left, Right. No diagonal movement.
  • Sprite rendering: Automatically updates the sprite direction and walk animation.
  • Collision checking: Queries the GridController before each move.
  • Movement speed: Configurable walk speed with optional running.

PlayerCharacter

The PlayerCharacter extends MCECharacterController with player-specific features:

  • Input handling (keyboard and gamepad).
  • Interaction triggers (pressing the action button while facing an NPC/object).
  • Encounter step counting.
  • Running/cycling speed modifiers.
  • Follower monster coordination.

GlobalGridManager

The GlobalGridManager handles cross-map navigation:

  • Manages warp tiles that transition between scenes.
  • Handles additive scene loading for connected maps.
  • Preserves player state across transitions.
  • Manages the loading screen / fade transition.

Tile Types

MCE supports several tile behaviors:

Tile TypeDescriptionImplementation
NormalStandard walkable tileDefault
BlockedCannot be walked onCollision tilemap layer
GrassWalkable, triggers encounter checksEncounterTile component
WaterRequires Surf to traverseTileType.Water
LedgeCan only be crossed in one direction (jumping down)TileType.Ledge + direction
BridgeAllows walking over other tiles on a different layerTileType.Bridge
Slippery (Ice)Character slides until hitting an obstacleTileType.Slippery
WaterfallClimbable with specific HMTileType.Waterfall
WarpTransitions to another sceneWarp configuration
SpinningForces the character to spin in a directionTileType.Spinning

Setting Up a Map

Step 1: Create the Tilemap Structure

MCE maps use a standard Unity Tilemap hierarchy:

Grid (Grid component)
└── Ground (Tilemap, TilemapRenderer, sorting order 0)
└── GroundOverlay (Tilemap, TilemapRenderer, sorting order 1)
└── Collision (Tilemap, TilemapCollider2D)
└── Encounters (EncounterTile components)
└── Actors (NPC GameObjects)

Step 2: Paint the Map

Use the Tile Palette (Window > 2D > Tile Palette) to paint your map:

  1. Ground layer: Base terrain (paths, grass, dirt, water edges).
  2. GroundOverlay layer: Decorations on top of ground (flowers, rocks, shadows).
  3. Collision layer: Mark impassable tiles (walls, trees, boulders).

Step 3: Add the GridController

  1. Select the Grid root GameObject.
  2. Add the GridController component.
  3. It will automatically detect the tilemap layers and build the collision map.

Step 4: Configure SceneInfo

Each map scene needs a SceneInfo component (or a SceneInfoAsset ScriptableObject):

FieldDescription
Scene NameDisplay name for the location (shown in the header)
RegionWhich region this map belongs to
Scene TagTags for game logic (e.g., "Cave", "Town", "Route")
BGMBackground music for this map
Wild EncountersDefault encounter set for this map

Special Terrain

Bridges

Bridges allow characters to walk over tiles that would normally be impassable (like water):

  1. Create a bridge tilemap layer with higher sorting order.
  2. Add bridge tiles where the walkway crosses over water.
  3. Set the TileType to Bridge on those tiles.
  4. The character will walk on the bridge layer when stepping onto it.

Bridge logic handles the Z-ordering automatically -- the character renders above the water but below bridge railings.

Slippery Tiles (Ice)

On ice tiles, the character slides in the direction they are moving until they hit a wall or a non-ice tile:

  1. Set the TileType to Slippery on ice tiles.
  2. The MCECharacterController will override input and continue the movement direction.
  3. Add walls or obstacles to create ice puzzle layouts.

Ledges

Ledges are one-way tiles -- the character can jump down but not climb back up:

  1. Set the TileType to Ledge and configure the direction (the direction the character jumps).
  2. A short hop animation plays when the character crosses the ledge.
  3. Ledges are commonly used to create shortcuts in routes.

Waterfalls

Waterfalls can be climbed with the appropriate HM or ability:

  1. Set TileType to Waterfall on the waterfall tiles.
  2. Configure the required ability or HM.
  3. When the player faces the waterfall and uses the ability, the character ascends.

Cross-Map Transitions

Warp Setup

To connect two maps:

  1. Place a warp tile or a warp actor at the edge or door of the source map.

  2. Configure the warp with:

    • Target Scene: The scene to load.
    • Target Position: Where the player appears in the target scene (tile coordinates).
    • Target Direction: Which direction the player faces after warping.
    • Transition Type: Fade, door, cave entrance, etc.
  3. The GlobalGridManager handles the scene transition:

    • Fades the screen.
    • Unloads the current scene.
    • Loads the target scene additively.
    • Places the player at the target position.
    • Fades back in.

Map Connections (Seamless)

For maps that connect directly (e.g., Route 1 connects to Route 2 at the north edge):

  • Place warp tiles along the entire connecting edge.
  • Set all warps to the same target scene with corresponding positions.
  • Use a quick fade for the transition.

Player Movement Configuration

On the PlayerCharacter component:

FieldDescriptionDefault
Walk SpeedTiles per second when walking4
Run SpeedTiles per second when running8
Bike SpeedTiles per second when cycling12
Can RunWhether the player can run (B button)true
Has BikeWhether the player has unlocked the bicyclefalse
Step CounterTracks total steps for encounters and egg hatchingauto

Monster Followers

MCE supports a follower system where the first monster in the player's party walks behind them in the overworld:

  • The MonsterFollowerController manages the follower's position and sprite.
  • The follower follows the player's movement path with a one-tile delay.
  • Follower sprites are configured per-species in the MonsterEntry.
  • The player can interact with their follower (turn and press action button) to see a flavor text reaction.
Follower Sprites

If a monster species does not have an overworld follower sprite assigned, the follower will not appear. Use the Art Studio to generate follower spritesheets, or create them manually as 4-direction walk cycle sheets.

Best Practices

  1. Keep collision layers consistent. Use the same collision tile for all impassable terrain.
  2. Test warp connections both ways. Make sure you can go from A to B and back from B to A.
  3. Use SceneTags for encounter logic. Rather than hardcoding map names, tag maps as "Cave", "Water", "Forest", etc.
  4. Optimize large maps. Very large tilemaps (>200x200) can impact performance. Consider splitting into multiple connected scenes.
  5. Test with gamepad. Grid movement should feel responsive on both keyboard and controller.