Set Up Your First Battle
This guide shows you how to configure an encounter zone, trigger a wild battle, and understand the battle flow. By the end, you will have a working battle that you can test in the editor.
Prerequisites
- MCE is installed and the setup wizard has been completed.
- You have at least one monster in your database (the included 151 or one you created).
- You have a scene with a player character and a grid-based tilemap.
Step 1: Create an Encounter Zone
Wild battles are triggered by encounter tiles on your tilemap. Here is how to set one up:
- In your scene hierarchy, select the tilemap layer where you want encounters (typically a "Grass" or "TallGrass" layer).
- Create a new empty GameObject as a child of your grid:
Right-click > Create Empty, name itGrassEncounters. - Add the EncounterTile component to this GameObject.
- Position it on the tiles where encounters should happen using the tile-based coordinates.
Alternatively, you can paint encounter zones directly on a dedicated tilemap layer using MCE's encounter tile types.
Step 2: Configure the Encounter Table
The EncounterTile component references a WildEncountersSet ScriptableObject. Create one:
Assets > Create > OpenMon > Wild Encounters Set- Name it something descriptive, like
Route1_GrassEncounters. - Open the ScriptableObject and configure the encounters:
| Field | Description |
|---|---|
| Monster | The MonsterEntry SO for the species that can appear |
| Min Level | Minimum level of the wild monster |
| Max Level | Maximum level of the wild monster |
| Probability | Encounter weight (higher = more common) |
| Encounter Type | When this encounter can trigger (Walking, Surfing, Fishing, etc.) |
Add multiple entries to create variety. For example:
| Monster | Level Range | Probability |
|---|---|---|
| Flameleon | 3-5 | 40 |
| Leaflet | 3-5 | 40 |
| Sparkit | 4-6 | 20 |
- Assign this
WildEncountersSetto yourEncounterTilecomponent's Encounters field.
Step 3: Set Up the Battle Scene
MCE uses a dedicated battle scene that loads additively when a battle starts. You need:
- A BattleLauncher component in your overworld scene. This is typically on a persistent manager GameObject. If you used the setup wizard, this should already exist.
- A Battle Scene configured in your build settings. The default battle scene is included with MCE.
The BattleLauncher handles the transition:
- Fades the screen.
- Loads the battle scene additively.
- Instantiates the
BattleManagerwith the correct parameters. - Returns to the overworld when the battle ends.
BattleManager Components
The BattleManager is the heart of the battle system. In the battle scene, you will find a GameObject with the BattleManager component, which uses a modular architecture with these key modules:
| Module | Purpose |
|---|---|
| BattlersModule | Manages battler instances on both sides |
| HealthModule | HP tracking, fainting, healing |
| MovesModule | Move execution, PP tracking, type effectiveness |
| ItemsModule | In-battle item usage |
| CaptureModule | Wild monster capture mechanics |
| AIModule | Enemy decision-making |
| AnimationModule | Battle animations and visual effects |
| AudioModule | Battle music and sound effects |
| StatusesModule | Status conditions (burn, poison, sleep, etc.) |
| BattlerStatsModule | Stat stages and modifications |
| BattlerSwitchModule | Switching between party members |
| RostersModule | Party management during battle |
| ScenariosModule | Battle type configuration (wild, trainer, etc.) |
| MegaModule | Mega Evolution activation |
| CharactersModule | Trainer sprite display |
You do not need to configure these individually. The BattleManager wires everything together automatically via Zenject dependency injection.
Step 4: Configure the BattleStateMachine
The BattleStateMachine drives the battle flow:
Start → Introduction → Turn Selection → Action Execution →
→ Check Fainted → Replace Fainted → Turn End →
→ [loop back to Turn Selection or] → Battle End → Results
The state machine is pre-configured in the battle scene prefab. Each state handles transitions automatically based on battle conditions.
Step 5: Test the Battle
-
Make sure your overworld scene has:
- A PlayerCharacter with a roster containing at least one monster.
- An EncounterTile with a configured
WildEncountersSet. - A BattleLauncher on a manager GameObject.
-
Press Play in the editor.
-
Walk your character into the encounter zone.
-
After a few steps (determined by the encounter rate), a battle will trigger.
To test battles immediately without walking around, you can:
- Set the encounter rate to 100% on your
EncounterTile. - Or use the
BattleLaunchercomponent directly and call its launch method from a test script.
Understanding the Battle Flow
When a battle starts, this is what happens under the hood:
- BattleLauncher receives an encounter trigger from the
EncounterTile. - A
BattleParametersobject is created with the wild monster's data. - The battle scene loads additively.
BattleManagerinitializes all modules.BattleStateMachineenters the Introduction state (shows the wild monster, plays cry).- The player is presented with action choices: Fight, Bag, Monster, Run.
- Actions execute in speed order.
- The loop continues until one side faints or the player runs/captures.
BattleResultParametersare sent back to the overworld (exp gained, items used, monster caught, etc.).- The battle scene unloads and the overworld resumes.
Battle Types
MCE supports several battle types out of the box:
| Type | Description |
|---|---|
| Wild | Single wild monster encounter, can capture |
| Trainer | NPC trainer battle, cannot capture, rewards money on win |
| Double | Two vs two battle format |
| Scripted | Story battles with special conditions |
The battle type is determined by the BattleType enum passed in BattleParameters.
Listening to Battle Events (DLL Users)
If you are using Lite, Basic, or Pro tier (no source code), you can still respond to battle events through the SDK:
using OpenMon.MCE.SDK;
public class MyBattleTracker : MonoBehaviour
{
[Inject] private IBattleSystem battleSystem;
private void OnEnable()
{
battleSystem.OnBattleStarted += HandleBattleStarted;
battleSystem.OnBattleEnded += HandleBattleEnded;
}
private void OnDisable()
{
battleSystem.OnBattleStarted -= HandleBattleStarted;
battleSystem.OnBattleEnded -= HandleBattleEnded;
}
private void HandleBattleStarted()
{
Debug.Log("A battle has started!");
}
private void HandleBattleEnded(bool playerWon)
{
Debug.Log($"Battle ended. Player won: {playerWon}");
}
}
See the Public API Guide for more on extending MCE without source code.
Troubleshooting
| Issue | Solution |
|---|---|
| Battle does not trigger | Check that the EncounterTile has a valid WildEncountersSet assigned |
| Black screen after encounter | Verify the battle scene is in your Build Settings scene list |
| Monster appears at level 0 | Ensure Min Level and Max Level are set in the encounter table |
| No battle music | Check that BattleManagerAudioModule has audio clips assigned |
| Crashes on battle start | Run MCE > Tools > Asset Validation to check for missing database references |
Next Steps
- Battle System Deep Dive -- Learn the full battle architecture.
- Move System -- Understand the 668+ move system.
- Battle AI -- Configure and customize enemy AI.