Debugging and Testing
To run several clients during development with Build And Run or Multiplayer Play Mode, see Building and Testing Multiplayer.
State Machine Debugging
The sample project makes extensive use of the Finite State Machine (FSM) addon to control both player and enemy behavior. For help debugging these state machines, please refer to the FSM addon documentation page.
Enemy AI Debugging
The sample includes a custom Enemy Inspector tool to help debug enemy behavior and enemy spawners during runtime. To use it:
- Open the Enemy Inspector window by selecting
Tools > Fusion Casual MMO > Enemy Inspector - Enter Play Mode in the Unity Editor
- Select an
EnemyorEnemySpawnerGameObject in the Scene view
For enemies, the inspector shows:
- Basic information like state authority, spawner ID and area ID
- Debug logging/drawing controls
- Stats including level, health and position
- Current and previous AI state
- Blackboard variables used by the AI (spawn position, target, line of sight etc.)
- NavMesh agent details like speed, path status and destination
For enemy spawners, the inspector displays:
- Basic spawner information
- Current enemy count
- List of all spawned enemies with their network IDs and state authorities
The inspector window updates in real-time as you play test the game, making it easier to track and debug enemy behavior.
Player AI
The sample includes a basic AI system for controlling player characters, which is useful for testing gameplay mechanics and large-scale scenarios.
The AI is implemented in the PlayerAI component and handles navigation, combat, area exploration, chest looting and ability usage using NavMesh for pathfinding.
During gameplay, you can toggle AI control for your own player character by pressing the I key.
When enabled, the AI:
- Navigates between different game areas, dashing from time to time while moving
- Searches for and engages enemies in combat
- Attacks enemy targets with melee attacks and the ultimate ability and stays clear of its own fire area effect
- Visits nearby chests and occasionally uses a portal to explore the area on the other side, remote portals are skipped in batch mode
- Travels to enemy spawners in the nearest areas when no enemies are detected, farther areas unlock as the player levels up
This AI system serves as the foundation for automated bot testing, where large numbers of AI-controlled players can join the game to stress-test the game systems and networking, see Large Scale Testing.
You can customize the AI behavior through the Inspector by modifying parameters such as wander areas, debug logging and other settings on the PlayerAI component located on the Player prefab.
Large Scale Testing
The sample includes support for large-scale testing with multiple connected clients using batch mode and multi-peer functionality.
There are two ways to perform large-scale testing:
Using Batch Files
The BatchTesting folder in the project root contains Windows batch files for running bot clients from a build:
| File | Description |
|---|---|
BatchStart-10Clients-Log1.bat to BatchStart-10Clients-Log4.bat |
Start 10 bot clients in two processes with 5 clients each, using the player name prefixes BotWin1- to BotWin4- and the log files Log1.log to Log4.log |
BatchKillAll-FusionCasualMMO.bat |
Terminates all Fusion Casual MMO.exe processes |
Readme.txt |
Short version of these steps |
- Build the game for Windows in Unity
- Copy the
.batfiles from theBatchTestingfolder to the build location (next toFusion Casual MMO.exe) - Run
BatchStart-10Clients-Log1.batto start 10 client instances that automatically connect to a session namedBatchTest - You can run the other
BatchStartfiles or run a batch file multiple times to add more clients (limited by your PC resources) - To terminate all
Fusion Casual MMO.exeprocesses, runBatchKillAll-FusionCasualMMO.bat
Each BatchStart file runs the following command twice, edit -clients to change the number of clients per process:
start "Fusion Casual MMO - 5 Clients" "Fusion Casual MMO.exe" -batchMode -nographics -clients 5 -bot -playerNamePrefix "BotWin1-" -logFile "Log1.log"
To monitor the behavior of all connected clients, you can join the game either through the Unity Editor or by launching a separate instance of Casual MMO.
Enter BatchTest as the room name to ensure you join the same session as the bots.
Using Unity Editor
You can also run batch mode simulation directly from the Unity Editor:
- Locate the
BatchModeManagerobject in theGamescene - Enable
Simulate Batch Modein the Inspector - Configure the number of clients and other settings as needed
- Start the game in Play Mode
The BatchModeManager spawns the specified number of client instances, each running with its own NetworkRunner and connecting to the same session.
This allows you to test networking behavior, game performance and gameplay mechanics at scale.
To get an overview of the project or runtime session stats, we recommend checking Fusion Inspector addon.
Last updated on
Back to top