This document is about: FUSION 2
SWITCH TO

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:

  1. Open the Enemy Inspector window by selecting Tools > Fusion Casual MMO > Enemy Inspector
  2. Enter Play Mode in the Unity Editor
  3. Select an Enemy or EnemySpawner GameObject 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
  1. Build the game for Windows in Unity
  2. Copy the .bat files from the BatchTesting folder to the build location (next to Fusion Casual MMO.exe)
  3. Run BatchStart-10Clients-Log1.bat to start 10 client instances that automatically connect to a session named BatchTest
  4. You can run the other BatchStart files or run a batch file multiple times to add more clients (limited by your PC resources)
  5. To terminate all Fusion Casual MMO.exe processes, run BatchKillAll-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:

  1. Locate the BatchModeManager object in the Game scene
  2. Enable Simulate Batch Mode in the Inspector
  3. Configure the number of clients and other settings as needed
  4. 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