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
GridControllerbefore 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 Type | Description | Implementation |
|---|---|---|
| Normal | Standard walkable tile | Default |
| Blocked | Cannot be walked on | Collision tilemap layer |
| Grass | Walkable, triggers encounter checks | EncounterTile component |
| Water | Requires Surf to traverse | TileType.Water |
| Ledge | Can only be crossed in one direction (jumping down) | TileType.Ledge + direction |
| Bridge | Allows walking over other tiles on a different layer | TileType.Bridge |
| Slippery (Ice) | Character slides until hitting an obstacle | TileType.Slippery |
| Waterfall | Climbable with specific HM | TileType.Waterfall |
| Warp | Transitions to another scene | Warp configuration |
| Spinning | Forces the character to spin in a direction | TileType.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:
- Ground layer: Base terrain (paths, grass, dirt, water edges).
- GroundOverlay layer: Decorations on top of ground (flowers, rocks, shadows).
- Collision layer: Mark impassable tiles (walls, trees, boulders).
Step 3: Add the GridController
- Select the Grid root GameObject.
- Add the
GridControllercomponent. - 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):
| Field | Description |
|---|---|
| Scene Name | Display name for the location (shown in the header) |
| Region | Which region this map belongs to |
| Scene Tag | Tags for game logic (e.g., "Cave", "Town", "Route") |
| BGM | Background music for this map |
| Wild Encounters | Default encounter set for this map |
Special Terrain
Bridges
Bridges allow characters to walk over tiles that would normally be impassable (like water):
- Create a bridge tilemap layer with higher sorting order.
- Add bridge tiles where the walkway crosses over water.
- Set the
TileTypetoBridgeon those tiles. - 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:
- Set the
TileTypetoSlipperyon ice tiles. - The
MCECharacterControllerwill override input and continue the movement direction. - 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:
- Set the
TileTypetoLedgeand configure the direction (the direction the character jumps). - A short hop animation plays when the character crosses the ledge.
- Ledges are commonly used to create shortcuts in routes.
Waterfalls
Waterfalls can be climbed with the appropriate HM or ability:
- Set
TileTypetoWaterfallon the waterfall tiles. - Configure the required ability or HM.
- When the player faces the waterfall and uses the ability, the character ascends.
Cross-Map Transitions
Warp Setup
To connect two maps:
-
Place a warp tile or a warp actor at the edge or door of the source map.
-
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.
-
The
GlobalGridManagerhandles 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:
| Field | Description | Default |
|---|---|---|
| Walk Speed | Tiles per second when walking | 4 |
| Run Speed | Tiles per second when running | 8 |
| Bike Speed | Tiles per second when cycling | 12 |
| Can Run | Whether the player can run (B button) | true |
| Has Bike | Whether the player has unlocked the bicycle | false |
| Step Counter | Tracks total steps for encounters and egg hatching | auto |
Monster Followers
MCE supports a follower system where the first monster in the player's party walks behind them in the overworld:
- The
MonsterFollowerControllermanages 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.
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
- Keep collision layers consistent. Use the same collision tile for all impassable terrain.
- Test warp connections both ways. Make sure you can go from A to B and back from B to A.
- Use SceneTags for encounter logic. Rather than hardcoding map names, tag maps as "Cave", "Water", "Forest", etc.
- Optimize large maps. Very large tilemaps (>200x200) can impact performance. Consider splitting into multiple connected scenes.
- Test with gamepad. Grid movement should feel responsive on both keyboard and controller.